Lesson 1 · Domain 1 — Agentic Architecture & Orchestration (27% of exam)

The Agentic Loop

Every agent you'll design for this exam — customer support bot, research coordinator, CI reviewer — runs on the same underlying mechanism. Get this one loop exactly right and a large share of Domain 1's "knowledge of" bullets fall out for free.

The mechanism

An agentic loop is nothing more than: send a request to Claude, inspect what it decided to do, act on that decision, and repeat. The entire "decision" is carried in one field on the response: stop_reason.

Each time you execute tools, their results get appended to the conversation history as a new message, and you send the whole growing conversation back to Claude for the next turn. This is why tool results accumulate in context — a fact you'll return to in Domain 5 when context management becomes the problem.

while (true) {
  const response = await client.messages.create({
    messages: conversation,
    tools,
    ...
  });
  conversation.push(response.toMessage());

  if (response.stop_reason === "end_turn") {
    return response; // done — show this to the user
  }

  if (response.stop_reason === "tool_use") {
    for (const block of response.content) {
      if (block.type === "tool_use") {
        const result = await executeTool(block.name, block.input);
        conversation.push(toolResultMessage(block.id, result));
      }
    }
    // loop continues — send the updated conversation back
  }
}
Three anti-patterns the exam tests directly

Why this matters beyond the exam

This loop is the substrate under the Claude Agent SDK, Claude Code itself, and any custom agent you build with the Messages API directly. Every other Domain 1 topic — subagent orchestration, hooks, session forking — is a variation played on top of this same loop.

Primary source: read Anthropic's own tool-use / stop_reason reference in the Claude API docs and the Agent SDK overview — this lesson compresses both down to the one mechanism the exam actually probes.

Check your understanding

Q1. Your agentic loop checks stop_reason after each API call. Which condition should terminate the loop and return the response to the user?
Q2. stop_reason on the response is tool_use. What should the loop do next?
Q3. Why append each tool result back into conversation history before the next API call?

Stuck on any of this, or want to see how this loop maps onto the Agent SDK's own TypeScript types? Just ask — I'm your teacher for this workspace, not just the lesson author.