Tool calls
Despite the suggestive terminology, a language model cannot directly execute code, open network sockets, query databases, or modify files. When a model "calls a tool", it simply outputs structured text—typically a JSON block specifying a function name and key-value arguments. The responsibility for executing that request falls entirely upon the calling application.
Whether your caller is a twenty-line script or an advanced autonomous harness with interactive approval prompts, the execution decision remains with the host software. If a model emits a structured block requesting a database deletion and that database vanishes a moment later, the model didn't delete it; the host application evaluated the request and executed the command.
Anatomizing a tool definition
A Toola capability the caller is willing to run on the model's behalf, offered to the model as a name, a description, and a schema.Full glossary entryIntroduced in Tool calls represents an external action the calling environment is prepared to execute on behalf of the model. To make a capability discoverable, the caller registers a Tool definitionthe name, description, and JSON Schema sent in the context so the model knows a tool exists. Every definition costs tokens on every call.Full glossary entryIntroduced in Tool calls in the request payload, providing a name, a description, and a JSON Schema detailing expected arguments:
{
"name": "get_weather",
"description": "Get the current weather for a city. Use when the user asks about conditions right now, not a forecast.",
"input_schema": {
"type": "object",
"properties": {
"city": { "type": "string", "description": "City name, e.g. Leeds" },
"unit": { "type": "string", "enum": ["celsius", "fahrenheit"] }
},
"required": ["city"]
}
}
Because JSON schemas are dense with punctuation and symbols, they consume significantly more tokens per character than standard English prose. A single schema with descriptive parameter documentation easily spans 200 to 500 tokens. Registering twenty tools across several connected MCP servers can quickly add 4,000 to 8,000 tokens of static overhead to every request. Because API requests are stateless, these schemas must be re-transmitted on each turn—making prompt caching crucial for managing costs.
Your registered tool list functions as a budget: exposing dozens of tools consumes substantial standing context and increases the risk of the model selecting an incorrect or ambiguous tool.
The tool-calling cycle
A typical tool execution follows a coordinated five-step sequence:
- The caller packages the tool definitions, conversation history, and user question into the request.
- The model recognizes that answering requires external data, halts prose generation, and emits a structured Tool calla structured block the model emits naming a tool and its arguments. It executes nothing; the caller decides whether to run it.Full glossary entryIntroduced in Tool calls block.
- The caller parses the tool call and executes the real-world operation (such as making an HTTP request or querying a database).
- The caller formats the operation's output into a Tool resulta tool's output, appended to the conversation as a message and sent back to the model. It is text, and it costs context like any other text.Full glossary entryIntroduced in Tool calls message, appends it to the transcript, and sends a follow-up request to the model.
- The model reads the execution output in the updated history and generates its conversational response.
Notice that on step 5, the model has no innate memory of requesting the tool on step 2. It understands the workflow purely because the caller resent the original question, the tool invocation, and the resulting payload within the message history.
Providers also refer to this mechanism as Function callinganother name for tool calling, used by several vendors for the same mechanism of emitting a structured call for the caller to execute.Full glossary entryIntroduced in Tool calls. While API parameter names vary across vendors, the underlying protocol is identical.
An interaction can conclude with the model providing direct text, or with an execution refusal:
Declining to run a tool is a completely valid conversational state. If a user rejects a file deletion prompt, the harness returns a message stating "Action declined by user". The model digests that feedback, adjusts its plan, and offers an alternative approach.
Tool outputs become prompt context
Whatever data a tool returns is serialized into the message history as plain text. It consumes tokens, incurs billing, and impacts attention like any other prompt element.
If a database tool returns a 200 KB raw JSON response, that single invocation injects approximately 50,000 tokens into the conversation history. On a 200,000-token window, a quarter of your available capacity is spent on redundant database keys the model will never inspect. Optimization belongs in the tool implementation: filter fields to what is strictly necessary, paginate long lists, and return compact summaries.
Schema design directly drives accuracy
When a model selects which tool to invoke, it relies entirely on the tool names and documentation strings supplied in the schema. It cannot inspect the underlying source code or test an endpoint experimentally.
Ambiguous descriptions lead to frequent invocation mistakes. A tool generically named search with the description "searches data" will be called indiscriminately for unrelated tasks. Similarly, registering both get_user and lookup_customer without specifying which connects to the CRM versus internal authentication will cause the model to alternate unpredictably between them.
Leveraging JSON Schema validations—such as strict enum constraints and explicit required lists—prevents invalid calls before they happen. An enum specifying ["celsius", "fahrenheit"] eliminates invalid variations like "C" or "metric". Many providers also offer strict schema modes that enforce schema adherence during token decoding, mathematically guaranteeing that emitted JSON matches your schema specification.
However, syntactic schema compliance does not guarantee factual validity. A model can emit a syntactically valid order_id that was fabricated or hallucinated from conversational context. The executing environment must always validate arguments, enforce user authorization boundaries, and sanitize inputs before performing backend operations.
Name the tool after the action it performs. Use one verb and one noun.
- Write a description that says when to use the tool.
- Add a second sentence that says when not to use it.
- Give every parameter a description.
- Use an
enumfor any parameter with a fixed set of values. - Mark a parameter
requiredwhen the tool cannot run without it. - Return the smallest useful result. Page long lists.
- Validate every argument in the executing code before you act on it.
- Do not offer two tools whose descriptions overlap. Merge them or rename them.
Handling parallel tool calls
Modern models can emit multiple tool invocation requests in a single generation step. These Parallel tool callsseveral tool-call blocks in one reply, which the caller may run concurrently. Every one of them needs a matching result.Full glossary entryIntroduced in Tool calls allow the caller to execute independent tasks concurrently—such as fetching weather across four cities or reading three separate files—collapsing multiple sequential round-trips into one.
When processing parallel calls, the harness must return a corresponding result for every requested tool call ID; omitting an ID results in an API validation error. If you are registering tools that trigger irreversible side effects, many providers allow disabling parallel tool execution to ensure actions occur strictly one at a time.
Resilient error handling
Tools inevitably experience real-world failures: network timeouts, database connection errors, or missing records.
Throwing an uncaught exception out of the agent loop aborts the entire conversation. In contrast, returning the error message to the model as the tool result allows it to self-correct. For example, when handed Error: order 88213 not found in active orders, the model will often pivot to query historical archives or search by customer name. Providing descriptive, actionable error strings helps the model decide its next recovery step.
Structured output without execution
When an application needs predictable data formatting without invoking external tools, it uses Structured outputforcing the model's reply to match a JSON Schema, with no tool and no execution involved. The same schema machinery pointed at the answer rather than at an action.Full glossary entryIntroduced in Tool calls. In this pattern, the caller supplies a JSON Schema and constrains the model's textual completion to match that schema. No external code executes; the model simply produces guaranteed valid JSON.
Use structured output when extracting structured records from unstructured text, such as parsing an invoice into database fields. Use tool calling when the model must dynamically retrieve information or trigger actions in external systems.
Once tool calling is operational, the natural progression is orchestrating multi-step autonomous workflows—the foundation of the agentic loop. Expanding toolsets via modular extensions is covered in skills, plugins, and MCP.
Terms introduced
- Tool: a capability the caller is willing to run when the model asks for it.
- Tool definition: the name, description, and JSON Schema sent in the context so the model knows a tool exists.
- Tool call: a structured block the model emits naming a tool and its arguments. It executes nothing.
- Tool result: the tool's output, appended to the conversation as a message and sent back to the model.
- Function calling: another name for tool calling, used by several vendors for the same mechanism.
- Parallel tool calls: several tool-call blocks in one reply, which the caller may run concurrently.
- Structured output: forcing the model's reply to match a JSON Schema, with no tool and no execution involved.
How providers do it
The loop is the same everywhere. What differs is what the pieces are called and, in one case, whether the result goes back as a message or as its own item.
| Concept | Anthropic | OpenAI | |
|---|---|---|---|
| Tools parameter | tools | tools | tools |
| Schema field | input_schema | parameters | parameters |
| Model's call | tool_use block | function_call output item | function_call step |
| Result goes back as | tool_result block in a user message | function_call_output input item | function_result input |
| Arguments arrive as | A parsed object in input | A JSON-encoded string in arguments | An object in arguments |
| Disable parallel calls | tool_choice.disable_parallel_tool_use | parallel_tool_calls: false | No documented flag |
| Strict tool schema | strict: true | strict: true | tool_choice mode validated |
| Structured output | output_config.format | text.format | response_format |
| Built-in server-side tools | Web search, web fetch, code execution, advisor, tool search | Remote MCP tool; others not checked | google_search, code_execution, google_maps, computer_use, file_search |
Every row is confirmed except Google's parallel-call flag, which no current documentation appears to offer, and the breadth of OpenAI's built-in tool list. Both are marked unconfirmed in the tabs below.
The row that costs the most to get wrong is the arguments one. OpenAI hands you a JSON string to parse; the other two hand you an object. Code that assumes the wrong one fails on the first tool call rather than in testing.
- Anthropic
- OpenAI
What this maps to: The Messages API takes a tools array and answers with a tool_use content block. Anthropic calls the whole thing tool use, and notes that "function calling" means the same. It draws a line between client tools, which your code executes, and server tools, which run on Anthropic's infrastructure and return their results inside the same response.
| Question | Answer | Status |
|---|---|---|
| What is the tools parameter called | tools, an array on the Messages API request | confirmed |
| What is in a tool definition | name, description, and input_schema (a JSON Schema object) | confirmed |
| What is the response block called | tool_use, carrying id, name, and input. The message ends with stop_reason: "tool_use" | confirmed |
| How does a result go back | A tool_result block in a user message, with tool_use_id matching the call and content holding the output | confirmed |
| Are parallel tool calls supported | Yes. Turn them off with tool_choice: {"type": "auto", "disable_parallel_tool_use": true} | confirmed |
| What else can tool_choice do | auto, any, tool (name one), and none | confirmed |
| Is the schema enforced | Yes, with strict: true on a custom tool definition. Requires additionalProperties: false | confirmed |
| Is there a structured output mode | Yes. output_config: {"format": {"type": "json_schema", "schema": {...}}}, strictly enforced and not a beta | confirmed |
| Are there server-side built-in tools | Yes: web search, web fetch, code execution, advisor, and a tool search tool for working with very large tool sets | confirmed |
| Are there client tools with Anthropic's own schema | Yes: bash, text editor, memory, computer use, browser use. Your code still executes them | confirmed |
| What do the definitions cost | Beyond the tokens in tools itself, the API inserts a tool-use system prompt. On Claude Opus 5 that is 286 tokens for auto or none, and 406 for any or tool | confirmed |
Their vocabulary
| Standard term | Their term |
|---|---|
| Tool call | Tool use, tool_use block |
| Tool result | tool_result block |
| Tool definition schema | input_schema |
| Structured output | Structured outputs, output_config.format |
| Tool the provider executes | Server tool |
| Tool your code executes | Client tool |
Where to look
The usage block on every response reports input and output tokens, so the cost of a fat tool list shows up there. Server tools that bill per use, such as web search, publish their rates on their own documentation page rather than in the token count.
Last verified: 2026-09-09 against platform.claude.com/docs/en/agents-and-tools/tool-use/overview and platform.claude.com/docs/en/build-with-claude/structured-outputs.
What this maps to: In the Responses API a tool goes in tools and the model answers with an output item of type: "function_call". The result goes back as a separate input item rather than as a message, which is the main shape difference from the other providers on this page.
| Question | Answer | Status |
|---|---|---|
| What is the tools parameter called | tools. Each entry has type, name, description, parameters (JSON Schema) and optionally strict | confirmed |
| What is the response item called | An output item with type: "function_call", carrying call_id, name, and arguments | confirmed |
| What form are the arguments in | A JSON-encoded string. Your code parses it | confirmed |
| How does a result go back | An input item with type: "function_call_output", with call_id matching the call and output holding the result | confirmed |
| Are parallel tool calls supported | Yes. Set parallel_tool_calls: false to get zero or one call per turn | confirmed |
| Is the schema enforced | Yes, with strict: true on the tool. Requires additionalProperties: false and every field listed in required; optional fields are typed ["string", "null"] | confirmed |
| Is there a structured output mode | Yes. text: {"format": {"type": "json_schema", "strict": true, "schema": {...}}}. A reply can still be cut short by a token limit or a refusal, so check status and incomplete_details | confirmed |
| Are there server-side built-in tools | Yes, including a remote MCP tool of type: "mcp". Others such as web search and file search are documented separately | unconfirmed; the MCP tool was checked today, the rest of the built-in list was not |
| What is the Chat Completions equivalent | Older shape with tool_calls on the message and a tool role for results | unconfirmed; not read today |
Their vocabulary
| Standard term | Their term |
|---|---|
| Tool call | Function call, function_call output item |
| Tool result | function_call_output input item |
| Tool definition schema | parameters |
| Structured output | Structured Outputs, text.format |
| Strict schema enforcement | strict: true |
Where to look
The response's output array holds every item in order, so a turn with three function calls in it is three output items before any text. call_id is the field that matches a result to its call.
Last verified: 2026-09-09 against developers.openai.com/api/docs/guides/function-calling, developers.openai.com/api/docs/guides/structured-outputs and developers.openai.com/api/docs/guides/tools-connectors-mcp.
What this maps to: Google documents function calling on the Interactions API, POST /v1beta/interactions. A tool goes in tools, the model answers with a function_call step, and the result goes back as a function_result. The documentation is blunt about the point this page makes: "The model doesn't execute the function itself."
| Question | Answer | Status |
|---|---|---|
| Which API is this | The Interactions API, POST /v1beta/interactions | confirmed |
| What is the tools parameter called | tools. Each declaration uses "type": "function" with name, description, and parameters (JSON Schema) | confirmed |
| What is the response called | A step with "type": "function_call", carrying name, arguments, and id | confirmed |
| How does a result go back | An input with "type": "function_result", carrying name, call_id, and result | confirmed |
| Are parallel function calls supported | Yes, several independent calls in one turn | confirmed |
| Is there a way to force or forbid a call | generation_config.tool_choice, with modes auto (default), any, none, and validated | confirmed |
| Is there a way to disable parallel calls | No flag found in the function calling guide | unconfirmed; is there an equivalent of parallel_tool_calls: false? |
| Are sequential, dependent calls supported | Yes. Google calls this compositional function calling, where one call's result feeds the next | confirmed |
| Is there a structured output mode | Yes. response_format: {"type": "text", "mime_type": "application/json", "schema": {...}}. Python and JavaScript SDKs accept Pydantic and Zod schemas | confirmed |
| Is the structured output strictly enforced | The JSON structure is guaranteed. The docs still tell you to validate the values | confirmed |
| Are there built-in tools | Yes: google_search, code_execution, google_maps, computer_use, file_search, and remote MCP servers | confirmed |
| What about the older generateContent shape | Earlier documentation used functionDeclarations, a functionCall part and a functionResponse part, with toolConfig.functionCallingConfig.mode | unconfirmed; not read today, and the current guide documents the Interactions API instead |
Their vocabulary
| Standard term | Their term |
|---|---|
| Tool call | Function call, a function_call step |
| Tool result | function_result |
| Tool definition schema | parameters |
| Structured output | Structured output, response_format |
| Chained dependent calls | Compositional function calling |
Where to look
The interaction's step list is the record of the turn: every function_call and every function_result appears in it in order, so a loop that stalled shows which call had no result against it.
Last verified: 2026-09-09 against ai.google.dev/gemini-api/docs/function-calling and ai.google.dev/gemini-api/docs/structured-output.