Tool calling: how a model uses your functions
What the model actually sees, what it sends back, and why the descriptions you write decide what it does.
A model can't run code. With tool calling (also called function calling) you send, alongside the conversation, a list of tools: each a name, a description and an input schema in JSON Schema. The model may reply with a request to call one, with arguments, instead of text. Your code decides whether to run it.
The model chooses tools almost entirely from the descriptions, so write them for a reader who knows nothing: what the tool does, when to use it, what it returns, and any limits. Narrow schemas help too: an enum of real names stops the model inventing one.
Treat every tool call as a request, not a command. Check the tool exists, validate the arguments, decide whether a person must approve, and send any error back as the result so the model can recover.
Cost. Free to practise with the practice model. With a real model, tool definitions are sent on every call and count as input tokens.
Use it when
- you're writing tools for an agent.
- an agent picks the wrong tool or invents arguments.
- you're reviewing someone else's agent design.
How it works
- Define
- Name, description, input schema.
- Offer
- Send the tool list with the conversation.
- Receive
- The reply is text or a tool call with arguments.
- Check and run
- Validate, approve if needed, run, return the result.
- Repeat
- Until the model answers or a limit is hit.
Options
- Few, focused tools
- Easier for the model to choose well; easier to secure.
- Many general tools
- Flexible, but more wrong choices and more risk.
Example. Kestwick Hotels' agent had a tool called query with the description 'runs a query'. It used it for everything. Splitting it into get_booking and list_rooms, each with a one-line purpose, fixed most of the wrong answers.
Don't confuse it with
- Tool description
- Read by the model to decide when to use the tool.
- Code comment
- Read by people; the model never sees it.
Words to know
- Tool calling
- A model replying with a request to run one of your functions.
- JSON Schema
- A standard way to describe the shape of JSON data.
- Arguments
- The values the model wants passed to the tool.
Where to look
- Your agent's tool list
Practise it
- Run an agent loop with a practice modelHow-to, Free
- Describe and check tools so the agent uses them wellHow-to, Free
Read it in the guide, next to the tasks and labs.
Open in DevOps, Hands On