1:1 mentoring with Big Tech AI engineers
LLM & Agentic

Inside a Tool Call

Step-by-step breakdown of an LLM tool call: request, schema validation, execution, and result handling with code examples.

Last updated

Foundations9 min readFirst readHow LLMs Call Tools

After this section you can

  • Trace one tool call through every message on the wire and name each field that matters
  • Build the follow-up request correctly, including parallel calls and failed tools
  • Explain where MCP’s JSON-RPC sits relative to the model’s tool_use blocks
05

Inside a Tool Call: The Exact JSON

You know the idea: the model asks, your code acts. This is what actually crosses the wire, field by field, and the handful of rules that make the next request succeed or fail.

Key idea

A tool call is a relay in four pieces. You send tool definitions; the model answers with a tool_use block and stops; your code runs the tool; you send back a tool_result with the same id. Then the model answers.

Four pieces, one relay. The id is what ties the call to its result.
1 · tools[] + question you describe each tool: name · description input_schema 2 · tool_use the model proposes a call id: "toolu_01A" stop_reason: tool_use 3 · your code runs it validate the input add your credentials call the real API 4 · tool_result you send the outcome back tool_use_id: "toolu_01A" is_error: false the model reads the result, then answers or calls another tool You own pieces 1, 3 and 4. The model only ever writes piece 2, and it is a proposal, not an action.

Related

More in LLM & Agentic

Get full access to all 74+ sections with code examples, diagrams, and interactive animations.

Unlock Premium