Agentic loops: CCAR-F task statement 1.1
CCAR-F · Agentic Architecture & Orchestration (27% of the exam)
Task statement 1.1 sits in Agentic Architecture & Orchestration, the largest CCAR-F domain at 27% of the exam. It tests whether you can build the loop that lets Claude call tools, read the results and decide what to do next until the task is finished.
What the official guide covers
The Claude Certified Architect Foundations exam guide (version 1.0, effective July 2026) lists this under task statement 1.1, "Design and implement agentic loops for autonomous task execution":
| Knowledge of | Skills in |
|---|---|
The loop lifecycle: send a request, inspect stop_reason ("tool_use" or "end_turn"), run the requested tools, return the results | Continuing the loop when stop_reason is "tool_use" and stopping when it is "end_turn" |
| How tool results are added to the conversation history so Claude can reason about the next step | Adding tool results to the conversation between iterations |
| The difference between model-driven decisions and fixed decision trees or tool sequences | Avoiding anti-patterns: parsing Claude's text to decide when to stop, using an iteration cap as the main stop rule, treating any text reply as "done" |
How the loop works
- Send the user's request, the system prompt and the tool definitions to the Messages API.
- Read
stop_reasonon the response. - If it is
"tool_use", the response contains one or moretool_useblocks. Run each tool in your own code. - Append Claude's response to the conversation, then add one user message that holds a
tool_resultblock for everytool_useblock. Each result carries the matchingtool_use_id. - Send the updated conversation back and repeat from step 2.
- If it is
"end_turn", Claude has finished. Use the response.
while True:
response = client.messages.create(model=MODEL, max_tokens=4096, tools=TOOLS, messages=messages)
messages.append({"role": "assistant", "content": response.content})
if response.stop_reason == "end_turn":
break # the task is finished
if response.stop_reason == "pause_turn":
continue # server tool paused: send the turn back as it is
if response.stop_reason != "tool_use": # max_tokens, refusal, stop_sequence, context full
raise RuntimeError(f"Loop stopped early: {response.stop_reason}") # handle per the table below
results = [run_tool(block) for block in response.content if block.type == "tool_use"]
messages.append({"role": "user", "content": results}) # all tool_result blocks, one message
The loop exits normally only on end_turn. Every other stop reason gets its own handling, set out in the table below. Claude chooses which tool to call next from what it has learned so far. Your code decides nothing about the order. That is the model-driven decision-making the guide refers to.
Rules that decide exam answers
- Stop on
stop_reason, not on text. A reply such as "I'll check the order now" is not a stop signal. Only"end_turn"means the task is finished. - Return every result in one message. When Claude calls several tools in one response, send all the
tool_resultblocks together in the next user message. Separate messages break the format and make Claude call tools one at a time. - Results come first. In the user message,
tool_resultblocks must come before any text. Nothing may sit between the assistant's tool call and the user's results. - Report failures as results. If a tool fails, return a
tool_resultwithis_error: trueand a clear message. Claude can then correct the input and try again. - An iteration cap is a safety net, not the stop rule. Keep a cap to catch runaway loops, but the normal exit is
"end_turn".
What to do with each stop_reason
stop_reason | What it means | What the loop should do |
|---|---|---|
tool_use | Claude is calling one or more tools | Run them, return every result, continue |
end_turn | Claude has finished | Use the response and exit |
max_tokens | The reply hit your token limit | Raise the limit or continue; a cut-off tool call must be retried with a higher limit |
pause_turn | A server-tool loop reached its iteration limit | Send the response back as it is to continue |
refusal | Claude declined to respond | Read stop_details; do not treat it as success |
stop_sequence | One of your stop sequences fired | Check which one and handle it |
model_context_window_exceeded | The conversation filled the model's context window | Use what was returned, then trim or summarise the history before continuing |
Agent loop or fixed workflow?
The exam also tests when not to use an agentic loop. Anthropic separates workflows, where your code fixes the order of steps, from agents, where Claude decides the next step from what it has learned.
| Situation | Better choice | Why |
|---|---|---|
| The steps are known and always run in the same order | Fixed workflow | Cheaper, faster and easier to test |
| The next step depends on what a tool returns | Agentic loop | Claude chooses the next tool from the results |
| A step must happen every time, such as a compliance check | Workflow step or hook, not a prompt instruction | Code guarantees it; Claude's choice does not |
Where it appears in the exam
Domain 1 is a primary domain in three of the six exam scenarios: Customer Support Resolution Agent, Multi-Agent Research System and Developer Productivity with Claude. Four scenarios are drawn for each exam, so expect loop questions in most sittings.
Two sample questions
These are original Timo practice questions. They are not official exam questions.
Build exercise
Build a loop with two tools, get_order and get_refund_policy, against the Messages API.
- Log
stop_reasonon every iteration and confirm the loop exits only onend_turn. - Ask a question that needs both tools and check that Claude calls them in one response and that you return both results in one user message.
- Make
get_orderfail for one order ID and returnis_error: truewith a clear message. Watch Claude correct the input and retry. - Add an iteration cap of 10 and log a warning if it is ever reached. If it is, find the cause instead of raising the cap.
Practise this topic
- Claude Certified Architect practice exam: free, 20 questions, no sign-up
- Claude Certified Architect hub
- CCAR-F study guide: all topics
- Worked example: Production Claude tool loop
- Next topic: 1.2 Coordinator and subagent patterns
Sources
- Claude Certified Architect Foundations Exam Guide, version 1.0, effective July 2026 (Anthropic), task statement 1.1
- Anthropic documentation: Stop reasons
- Anthropic documentation: Handle tool calls
- Anthropic documentation: Parallel tool use
- Anthropic: Building effective agents
By Amotion AI