Agents and tools · core
Tool calling and tool design
In tool calling the model asks for a function call with JSON arguments, and your code runs it and returns the result. Good tools are built around user tasks with clear descriptions, small results and useful errors.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- You send tool definitions (name, description, JSON Schema for arguments) with the messages. The model replies with a tool-call request. Your code validates the arguments, runs the function and sends back a tool result tied to the call id. The model never runs anything itself.
- Parallel calls: the model can ask for several tools in one turn. Run the independent ones together and return every result.
- Errors go back as results, marked as errors, so the model can fix its arguments or tell the user. Do not crash the loop.
- Authorisation lives in your code. The tool uses the signed-in user's identity from the session, never a user id that the model fills in.
- Design around user tasks, not around REST endpoints: one find_customer_orders tool is better than five low-level calls to chain.
- Descriptions say what it does, when to use it and when not to, with formats and units. Precise names and descriptions matter: a cancel tool described as change or cancel was used to cancel a booking that the user wanted to change.
- Results are short and relevant, with pagination or a count and ids for the next call. Raw JSON dumps waste the context.
- Writes: separate read and write tools, idempotency keys, confirmation for risky actions, and least privilege. Every tool definition costs input tokens on every call.
The red pen
Common traps: mistake → fix
Mistake: The model runs the function
Fix: your code runs it; the model only asks.
Mistake: The model can be trusted to pass the right user id
Fix: take identity from the session.
Mistake: A vague tool description is fine because the name explains it
Fix: the description is what the model reads to choose.
Easy to hard
Questions interviewers ask, easy to hard
- Explain tool calling from start to end. Who runs the function?
- Write a tool definition to look up order status.
- What makes a tool good or bad for a model?
- The agent cancelled a booking instead of changing it. Read the trace and say what went wrong.
- How do you handle tool errors?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.