Agentic Architecture & Orchestration27% of the exam

Agentic loops and stop_reason control

How a client-tool agentic loop works on the Messages API and in the Agent SDK: continue on stop_reason tool_use, branch on every other value, append full assistant turns and all tool_result blocks, and keep turn and budget caps as backstops that report the run as incomplete.

Official exam objective
Design and implement agentic loops for autonomous task execution

~8 min read · 11 practice questions ·

What the exam expects

  • Write loop control that continues on stop_reason "tool_use" and handles every other value it exits on.
  • Append each assistant response and its tool_result blocks to one running messages list.
  • Answer parallel tool calls correctly: one tool_result per tool_use block, all in the next user message, nothing after them.
  • Reject the named anti-patterns: parsing natural-language phrases, treating any text block as completion, or using an iteration cap as the primary stop.
  • Choose model-driven tool selection over hard-coded sequences for open-ended work, and read Agent SDK result subtypes.

Key terms: agentic loop (send, inspect stop_reason, run tools, return results, repeat); stop_reason (the response field that says why Claude stopped generating); tool_result (the user-turn block that answers a tool_use block by tool_use_id); ResultMessage (the Agent SDK message that ends the loop, with a subtype); backstop (a turn or budget cap that only catches runaway runs).

Key facts

Loop continue condition
Detail
stop_reason == "tool_use"; exit on any other value
Current stop_reason values
Detail
end_turn, max_tokens, stop_sequence, tool_use, pause_turn, refusal, model_context_window_exceeded
pause_turn
Detail
Server-tool loop hit its limit (default 10 iterations); send the response back as-is
refusal
Detail
Returned as a normal HTTP 200; stop_details names the category
Parallel results
Detail
One tool_result per tool_use, all in one user message, before any text
Tool failure
Detail
Return tool_result with is_error: true; the loop keeps running
SDK limits
Detail
max_turns (tool-use turns) and max_budget_usd; no limit by default
result field
Detail
Present only on subtype success
Sources for this section (5)
  • Why must the loop check stop_reason rather than whether the reply contains text?
  • When the response has stop_reason: "pause_turn", what should the application send next?
  • How must the loop answer a response with three tool_use blocks?
  • Why should code check the Agent SDK ResultMessage subtype before reading result?
  • When does a model-driven agent fit better than a hard-coded tool sequence?

The questions are free to read. Answers with their sources and self-grading are included with the pack.

Keep reading with the Claude Certified Architect - Foundations pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 30 lessons of the Claude Certified Architect - Foundations guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Inline practice questions and one-click topic practice (11 questions for this lesson)
  • An official source cited for every claim
  • An AI tutor that answers from the guide
  • Unlimited timed practice exams

Practice for the Claude Certified Architect - Foundations exam

Certifyforce is an independent study resource and is not affiliated with, endorsed by or sponsored by Anthropic. Claude is a trademark of Anthropic.