Allow-list and human approval
Tool calling lets a model ask your code to run a function: you describe tools with JSON schemas, the model replies with a tool name and arguments, your code validates and runs it, and the result goes back. An agent is that exchange in a loop with a step limit, an allow-list and human approval for risky actions.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write validate_args(parameters, args) that returns a list of problems for missing, unknown and wrongly typed arguments.
Write run_agent(model, tools, max_steps) with a step limit that returns the final answer or "gave up".
Write safe_dispatch(name, args, tools, risky, approve) with an allow-list and an approval gate.
Explain it without notes
Describe the sequence of messages in one tool-calling exchange.
Why does an agent loop need a step limit and argument validation?
How would you make a tool that deletes data safe to expose to a model?
Your agent sometimes loops, calling the same tool again and again. How do you prevent it, detect it and debug it?
Expected output
<tool_result>get_weather ran with {'city': 'Pune'}</tool_result>
refused: tool not on the allow-list
approval asked for send_email{'to': 'a@example.com'}: no
refused: a human did not approve
approval asked for send_email{'to': 'a@example.com'}: yes
<tool_result>send_email ran with {'to': 'a@example.com'}</tool_result>