Tool use, also called function calling, lets a language model reach beyond text. The application tells the model which tools exist. When a request needs one, the model replies with a structured request (the tool’s name and its arguments) instead of an answer. The application runs the tool, sends back the result, and the model carries on with real data in hand.
It covers what models are bad at on their own. The Toolformer paper (Schick and colleagues, 2023) opens with the paradox: language models can pick up new tasks from a few examples, yet struggle with arithmetic and factual lookup, where far simpler systems excel. A calculator, a search engine or a database query closes that gap.
How a tool call works
The diagram is the whole protocol, and its key point is that the model never executes anything. Using Anthropic’s API as a concrete example:
- Define. Each tool has a name, a description and an input schema written in JSON Schema. The description is what the model reads to decide when the tool applies, so it matters as much as the code behind it.
- Request. When the model wants a tool, the response ends with
stop_reason: "tool_use"and contains atool_useblock holding the arguments. - Execute. Your code runs the function: a weather lookup, a SQL query, a file edit.
- Return. You send the output back in a
tool_resultblock, and the model uses it to answer or to call another tool.
Some tools, such as web search, run on the provider’s side instead (“server tools” in Anthropic’s terms), but the shape of the exchange is the same.
From one call to an agent
Put steps 2 to 4 in a loop and let the model decide when it’s finished, and you have an AI agent. Retrieval-augmented generation fetches documents before every answer; with tools, looking something up becomes one choice among many that the model makes as it goes. Tool definitions and results all sit in the context window and cost tokens, which limits how many tools and how much output an agent can juggle. The Agentic Coding Harnesses course shows how coding agents wire this up.
The catch
A model can pick the wrong tool, misread a result, or fill in arguments it was never given: Anthropic’s docs note that when a required parameter is missing, some models ask for it while others may guess a plausible value. Tool results are also untrusted input, since a web page or file can contain text written to steer the model, so actions that delete data, send messages or spend money deserve a human confirmation step.