The full answer
The application sends the request, the tool definitions and the conversation so far. The model replies either with text or with one or more tool calls. The application runs those calls and sends the results back, and the cycle repeats. When the model replies without asking for a tool, that reply is the answer. Each round trip is one turn.
Step by step, on the Claude API
- Request. The application sends the system prompt, the user's message and the
toolslist (name, description, JSON schema for each). - The model decides. If it needs a tool, the response ends with
stop_reason: "tool_use"and containstool_useblocks. Each block has anid, the toolnameand theinput. - The application runs the tools. Your code checks each call (is it allowed, is the input valid?) and executes it. Read-only calls can run in parallel.
- Results go back. The next user message holds a
tool_resultblock for each call. Each block carries the matchingtool_use_idand the output, and setsis_error: trueif the call failed. The result blocks come first in that message. - Repeat. The model reads the results and decides again. A failed call is not the end: given a clear error message, it usually corrects the input and tries again.
- Finish. A response with no tool calls ends the loop. The Claude Agent SDK then emits a result message with the final text, the cost, token usage and a session id to resume from.
What grows with each turn
Every turn sends the whole conversation again, including every tool result so far. Cost per turn grows, and long runs approach the context window. That is why agent frameworks clear old tool results or summarise the history (compaction); the Agent SDK compacts automatically.
Where your code is in control
- Before a tool runs: permission checks, input validation, approval from a person.
- After it runs: trimming large outputs, marking errors, treating the result as untrusted text.
- Around the loop: a maximum number of turns, a budget, a timeout.
A common follow-up
"Who executes the tool?" Always your application, for client tools. The model only asks. Some providers also run server-side tools (web search, code execution) on their own machines, and their results come back in the same response.
Drawing this as a diagram, model → tool_use → your code → tool_result → model, is usually what the interviewer wants to see. The ReAct pattern (reason, act, observe) is the same loop under another name.
Last updated 16 October 2026
Sources