BrainyBeeBrainyBee
ExploreBlogStart Studying
HomeClaude Certified Architect - Foundations (CCAR-F)Reference: the tool-use round trip
Grounded reference505 words

Reference: the tool-use round trip

Claude Certified Architect - Foundations (CCAR-F) › Domain 1: Agentic Architecture & Orchestration

The tool-use round trip, from the API documentation

The exam guide describes the agentic loop in prose. This is the same loop as the API documents it: the exact message shapes, the exact field names, and the full set of values that decide whether your loop runs again.

Where this comes from

Every fact on this page was fetched from Anthropic's published documentation on 2026-08-30, and each section names the page it came from. Where the exam guide and the documentation differ, both are given.

One turn, in full

A client tool round trip is three messages. Your request defines the tool; Claude answers with a tool_use block; you run the tool and send a tool_result back.

  1. You send messages plus a tools array. Each tool carries a name, a description, and an input_schema.
  2. Claude replies with stop_reason: "tool_use" and one or more tool_use blocks. Each block has an id, a name, and an input object.
  3. You append two messages — the assistant turn verbatim, then a user turn whose content is a tool_result block carrying tool_use_id and content. The tool_use_id must match the id from step 2.
  4. You send again. Claude uses the result to answer.

Why the assistant turn has to go back too

The tool_use blocks live in Claude's own turn, and every tool_result refers to one of them by tool_use_id. Append only the results and those ids point at a message that is no longer in the conversation. This is the single most common shape error in a hand-written loop.

Where the code runs

The documentation splits tools by where they execute, and it is worth holding because it decides whether you write a handler at all.

KindRunsYou handle results?
Client toolsIn your applicationYes — you send tool_result
Anthropic-schema client toolsIn your applicationYes — schema is published, execution is yours
Server toolsOn Anthropic's infrastructureNo — results come back in the same response

bash and text_editor are client tools with Anthropic-published schemas. web_search, web_fetch and code_execution are server tools.

Every stop_reason value

This is the set the loop branches on. The exam guide keys two of them; the API returns seven.

ValueMeaningWhat you do
end_turnClaude finished naturallyUse the response
tool_useClaude is calling a toolRun it, append the result, send again
max_tokensHit the max_tokens you setTreat as truncated; raise the limit or continue
stop_sequenceEmitted one of your stop_sequencesRead the stop_sequence field for which
pause_turnServer-tool loop hit its iteration limitSend the assistant content back to continue
refusalDeclined on safety groundsRead stop_details; retry on a fallback model
model_context_window_exceededFilled the context window before max_tokensTreat the response as truncated

The negation bug

Write the loop as: continue while stop_reason is not end_turn. Every value you did not think about then behaves like tool_use. A truncated max_tokens response arrives on a normal 200, so nothing raises — the loop simply carries on as though Claude had asked for something. Branch on tool_use explicitly and handle the rest.

Two details the documentation is specific about: refusal returns HTTP 200, not an error, and the pause_turn iteration limit for server-side tool loops defaults to 10.

tool_choice

tool_choice constrains a single request. The default is {"type": "auto"}, which lets Claude decide whether to call a tool at all.

SettingGuarantee
autoNone — Claude may return text instead
anyA tool will be called, but not which one
tool with a nameThat specific tool is called
noneNo tool is called

disable_parallel_tool_use: true limits a turn to at most one tool call.

Two ways to make a tool call happen

The documentation notes that the boundary is steerable by prompt: an instruction to always call a tool first pushes Claude toward tool use. But a prompt is a request. When the requirement is that structured output comes back at all, tool_choice is the guarantee and the prompt is not.

Strict tool use

Adding strict: true to a custom tool definition makes Claude's calls match your schema exactly. That eliminates a class of shape error and does nothing about semantics — a schema-valid call can still put the right value in the wrong field.

Sources

  • Tool use overview — https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview (retrieved 2026-08-30)
  • Handling stop reasons — https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons (retrieved 2026-08-30)
All Claude Certified Architect - Foundations (CCAR-F) Study Resources

Related Notes

  • Domain 1: Agentic Architecture & Orchestration169 words
  • Domain 1 Project — build a support agent, then make it a team1,199 words
  • CCAR-F: how the exam is dealt194 words
  • Scenario 1: Customer Support Resolution Agent225 words
  • Scenario 2: Code Generation with Claude Code185 words
  • Scenario 3: Multi-Agent Research System199 words
  • Scenario 4: Developer Productivity with Claude197 words
  • Scenario 5: Claude Code for Continuous Integration168 words
  • Scenario 6: Structured Data Extraction185 words
  • Domain 2 Project — build tools your agent actually picks correctly919 words
  • Domain 2: Tool Design & MCP Integration157 words
  • Reference: configuring MCP servers244 words

Ready to study Claude Certified Architect - Foundations (CCAR-F)?

Practice tests, flashcards, and all study notes — free, no sign-up.

Start Studying

Ready to study Claude Certified Architect - Foundations (CCAR-F)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free
Claude Certified Architect - Foundations (CCAR-F) ResourcesExplore All HivesBlogHome

© 2026 BrainyBee. Free AI-powered exam prep.