How does tool calling work?
Agents and tools · Intermediate 3
Short answer
You describe tools to the model with a name, description and input schema. When a tool would help, the model replies with a structured request to call it with arguments. Your code runs the tool and sends the result back, and the model uses it to continue. The model never runs your code itself.
Deeper answer
The loop: send the user message and tool definitions; if the response stops for tool use, parse the requested tool and arguments, validate them, run the function, and send a tool result message; repeat until the model answers in text. Some providers also run certain server-side tools, such as web search, for you.
Quality depends heavily on tool design: clear names and descriptions, tight input schemas, and useful error messages returned as tool results. Validate arguments before acting, because the model can produce wrong or harmful ones, especially if its input was manipulated.
What a strong answer covers
- Tools described with name, description and schema
- Model returns a structured call with arguments
- Your code runs the tool and returns the result
- The model never runs code itself
Answer it out loud in the mock interview about 1 min
Follow-ups to expect
- What should your code return when a tool call fails?
- Why validate the arguments the model sends?
Common mistakes
- Saying the model executes the tool
- Writing vague tool descriptions and blaming the model for wrong calls
Learn it
- What are common failure modes of agents, and how do you guard against them?
- What kinds of memory can an agent have, and how do you implement them?
- Your agent ran overnight and ran up a large API bill. What probably happened, and what do you change?
- How would you design a harness for an agent that has to work on one task for several hours?
- What is the difference between an agent and a workflow?
- What are computer-use or browser agents good for, and what are their risks?
- What is context engineering, and why does it matter for agents?
- An agent completes a task correctly most of the time but sometimes goes badly wrong. How do you debug it?
- What makes a good tool for an agent?
- Design an agent that handles refund requests for an online store.
- You changed your agent's harness. How do you prove the change made it better?
- What are verification gates in an agent harness, and how would you add them to a coding agent?
- When should an AI agent ask a human for approval before acting?
- Explain state, nodes, edges and checkpoints in LangGraph.
- What are planning and reflection in agents, and when do they help?
- Two coding agents use the same model, but one solves far more of your tasks. Why could that be, and how would you find out?
- What is an agent harness, and what is harness engineering?
- What is the Model Context Protocol, and why does it matter?
- When is a multi-agent system worth it, and what are the risks?