Claude Certified Architect · आधारभूत

Module 1: Agent architecture and orchestration

Study notes written by Sanjay Shah. Not official Anthropic material. Facts marked "check before relying on it" may have changed.

Practice this module

On this page

Course: Claude Architect (Foundations): Design production systems with Claude · Study notes, our own words · Facts checked 2026-11-25

Exam domain: Agentic Architecture & Orchestration, 27% (official exam guide v1.1, November 2026)

Take first: Building with the Claude API (opens in a new tab) (free, Anthropic Academy). It covers the request format and tool use. These notes assume you know them and focus on the design decisions.

Video: Module 1 long video, "Most Claude 'Agents' Shouldn't Be Agents" (planned). Diagrams D1.1 to D1.4 below are the same ones used in the video.


What you'll be able to do

  • Choose the least autonomy that solves a problem: one call, a fixed workflow, or an agent loop, and say why.

  • Describe exactly what an agent loop is, who runs each step, and what makes it stop.

  • Design a coordinator with subagents: what each subagent gets, what it returns, and what runs in parallel.

  • Write a handoff brief that a subagent with an empty context can act on.

  • Decide which rules live in code (gates, identity, limits) and which can live in a prompt.

  • Spot the common orchestration mistakes in someone else's design.


Key ideas

1. Three shapes, in order of autonomy

Every Claude system you design is one of three shapes, or a mix of them.

One call. Input goes in, Claude answers, your code uses the answer. Classifying a ticket, summarizing a document, extracting fields from an email. Most useful Claude features are this shape. It is the cheapest, the fastest and the easiest to test, because each input gives you one output to check.

A workflow. Several Claude calls (and plain code) in a path that you fixed in advance. The common workflow patterns are:

PatternWhat it doesUse it when
ChainStep 1's output is step 2's input, with optional code checks between stepsThe task splits cleanly into stages, such as outline → draft → check
RouteA first call classifies the input, and code sends it down one of several pathsInputs fall into types that need different handling
Parallel (split)Independent parts run at the same time, and code merges themParts don't depend on each other: review a contract for price, term and liability at once
Parallel (vote)The same task runs several times or with different prompts, and code compares the answersYou want more confidence on a yes/no judgment
Orchestrator and workersA lead call decides the sub-tasks at run time, workers do them, the lead combinesYou can't know the sub-tasks in advance, but each one is bounded
Evaluate and improveOne call drafts, another scores against criteria, repeat a fixed number of timesClear quality criteria exist and a second pass measurably helps

Anthropic's public engineering article Building effective agents (opens in a new tab) describes these patterns. Read it once; it is short and it shapes how the whole topic is talked about.

An agent. Claude decides the path at run time. It picks a tool, sees the result, decides what to do next, and keeps going until it judges the task done. You give it tools, a goal and limits. You don't give it the steps.

The rule of thumb: if you can draw the steps before it runs, build a workflow. A workflow is cheaper, faster, easier to test and easier to explain to an auditor. Reach for an agent only when the path really depends on what the system finds along the way, such as an investigation where each answer changes the next question.

Most production systems are a mix: a workflow backbone with one agent step where open-ended work is unavoidable.

D1.1 Three shapes. Solid arrows are data, dashed arrows are a decision.

2. What an agent loop really is

"Agent" sounds like magic. The mechanism is small, and you should be able to draw it from memory.

  1. Your code sends Claude the conversation so far plus a list of tools (name, description, input schema).

  2. Claude replies. If it wants a tool, the reply contains one or more tool_use blocks and the response's stop_reason is tool_use.

  3. Your code runs the tool. Claude never runs a client tool itself. (Server tools that Anthropic runs for you, such as web search, are the exception.)

  4. Your code sends the result back as a tool_result block that refers to the tool_use_id. If the tool failed, it says so with the is_error flag.

  5. Repeat until stop_reason is end_turn, meaning Claude has finished and the last message is its answer.

Two consequences matter for design:

  • "Done" is decided by the stop reason, not by reading the text. Don't search Claude's words for "I'm finished" and don't ask it "are you done?". Check stop_reason. Handle the other values too. On 2026-11-25 the API docs list seven: end_turn, tool_use, max_tokens (cut off, so not a finished answer), stop_sequence, refusal, pause_turn (only from loops of server tools that Anthropic runs) and model_context_window_exceeded. Only end_turn means "finished normally". Every other value is a case your code must handle, not a reason to treat the reply as the answer.

  • Your code is in the middle of every step. That is where you put guards, logging, permission checks and identity. The model asks; your code decides whether to do it.

Every loop also needs guards that stop it even if the model never says it is done:

  • a maximum number of turns (tool round-trips),

  • a token or cost budget for the whole task,

  • a wall-clock timeout,

  • and a "no progress" check, such as the same tool called with the same input three times.

When a guard trips, the loop stops and reports what it was doing, what it found so far, and why it stopped. A guard that silently returns "done" is worse than no guard.

D1.2 The agent loop with guards. The guards and the permission check are code, not prompt.

3. Coordinator and subagents

When one agent has to do several kinds of work, a common design is a coordinator (also called an orchestrator or lead agent) that hands parts of the task to subagents, then combines what they return. Think hub and spoke: subagents report to the coordinator, not to each other.

Why split at all? Four real reasons:

  1. Context isolation. A subagent can read 40 log files and return 10 lines. The coordinator's context stays small and focused. This is often the main reason.

  2. Parallelism. Independent investigations run at the same time, so the whole task finishes sooner.

  3. Fewer tools per agent. Each subagent sees only the tools for its job. Fewer tools means better tool choice and a smaller blast radius if something goes wrong.

  4. Specialized instructions. A billing investigator gets billing rules; a policy retriever gets policy rules. Neither prompt has to cover everything.

The costs are just as real:

  • More tokens overall. Every subagent repeats some setup, and the coordinator reads every result.

  • More latency for small tasks. A subagent round-trip is slower than one direct tool call.

  • New failure points: a bad brief, a lost fact, a subagent that fails quietly.

So don't add subagents by default. Add one when a part of the task is big enough to pollute the main context, independent enough to run alone, or risky enough to deserve its own reduced tool set.

Parallel only when independent. Run subagents at the same time only if none needs another's result. "Look up the account" and "pull the billing history" can run together if both only need the customer ID. "Find the invoice, then check whether its payment cleared" cannot, because the second step needs the first one's answer.

Decide who decomposes. In a fixed fan-out, your code decides the subtasks (always account + billing + policy). In a dynamic orchestrator, the coordinator decides at run time. Fixed is easier to test. Dynamic handles unusual cases. A common failure of dynamic decomposition is too narrow a split: the coordinator breaks a broad question into sub-questions that together miss part of it. Give the coordinator a checklist of areas that must be covered, and have it say which areas it assigned and which it skipped.

4. Context handoff: the subagent starts blank

This is the idea people get wrong most often. A subagent does not see the coordinator's conversation. It starts with an empty context: its own system prompt, its tools, and whatever the coordinator writes in the task. If the coordinator says "check the billing issue we discussed", the subagent has no idea what was discussed.

So every handoff needs a brief with four parts:

  1. Goal. What question to answer, and why it matters.

  2. Known facts. IDs, amounts, dates, names, what has already been ruled out. Exact values, not "the customer".

  3. Limits. Read-only or not, which systems, how many turns, what not to do.

  4. Return format. The exact shape of the answer.

Every result should come back structured, with:

  • the answer,

  • the sources it relied on (record IDs, document names, queries),

  • a status (complete, partial, failed),

  • and what it could not check.

That last field is how failures stay visible. Module 5 builds on it.

A bad brief and a good brief for the same job:

Bad: "Look into the billing problem for this customer and let me know."

Good: "Goal: find why tenant T-4471 was charged twice in October. Known: customer ID C-20931; charges of 49.00 USD on 2026-10-01 and 2026-10-02; the customer says they have one subscription. Limits: read-only billing tools only; at most 6 tool calls; do not contact the customer. Return JSON: {finding, charge_ids[], cause, refund_suggested (bool), sources[], could_not_check[]}."

D1.4 Context handoff. Everything the subagent needs travels in the brief.

5. Prompts advise, code enforces

A prompt is a request. Claude follows instructions well, but "well" is not "always", and an attacker can try to talk it out of an instruction (prompt injection, covered in Module 4 and the Professional course). So sort your rules into two groups.

Rules that may live in a prompt: tone, priorities, how to explain things, which tool to try first. If Claude occasionally ignores one, the cost is a worse answer, not damage.

Rules that must live in code:

  • Money and irreversible actions. A refund above a limit hits a gate in code that sends it to a human. The model can propose the refund. It can't approve it.

  • Identity and tenancy. In a multi-tenant system, your code sets the tenant ID and user ID on every tool call from the authenticated session. The model never chooses them, so a confused or manipulated model can't read another tenant's data.

  • Permissions. Which tools exist for this agent at all. A subagent that should only read gets only read tools, not write tools plus a "please don't write" prompt.

  • Limits. Turns, budget and timeouts (section 2).

Where does the gate go? In the tool layer, between Claude's tool request and the real system. The "issue refund" tool checks the amount and either executes, or creates an approval task and returns "pending human approval" to the agent. The agent then tells the user honestly that a person will review it.

6. The human in the loop is a design element

Put people where their judgment matters and where a mistake is expensive, not everywhere. Three placements:

  • Approve before action: refunds over a limit, posting to a ledger, emailing a customer. The agent prepares, a person approves.

  • Review a queue: low-confidence or rule-flagged outputs go to a queue. The rest flow through, and a sample is checked (Module 5).

  • Take over: the customer asked for a human, or the agent hit a limit. The handover carries a summary of what was done, so the person doesn't start from zero.

When you design the human step, design what the person sees: the proposed action, the reason, the sources, and one-click approve or reject. A person handed a wall of agent transcript will rubber-stamp it.


Worked example 1: support-ticket resolution, v1 to v3

The system: support tickets for a multi-tenant SaaS platform I build (made generic here). Tickets arrive by email and chat. Most are simple ("how do I reset my password?"). A few need investigation across billing, account and policy data. Refunds above a limit need a human.

v1: one agent with every tool. One system prompt, 14 tools (account lookup, billing, refunds, knowledge base search, email, ticket updates, and more). It worked in the demo. In production:

  • It often picked the wrong tool, because get_customer and lookup_account looked alike.

  • Simple FAQ tickets took 6 to 10 tool calls, because the agent "investigated" everything. Slow and expensive.

  • Once, it approved a refund above the limit, because the limit existed only in the prompt.

v2: a router workflow. A first Claude call classifies the ticket: FAQ, account change, billing question, or complex. Code routes it. FAQ tickets get a knowledge-base search (code) and one drafting call, then a support agent reviews the draft before it is sent. This handled about 80% of tickets with one or two calls each. The refund tool was removed from this path entirely.

v3: a coordinator for the hard 20%. Tickets classified "complex" go to a coordinator agent. It sends three briefs in parallel to three subagents, each with only its own read-only tools:

  • account lookup (Accounts DB),

  • billing investigator (Billing API, read-only),

  • policy retriever (policy knowledge base).

Each returns a structured result with sources. The coordinator combines them into a proposed action. If the action is a refund over the limit, a gate in code sends it to a human for approval. Every tool call carries the tenant ID, injected by code from the ticket's authenticated tenant.

D1.3 Support system v3. Every tool call carries a tenant ID set by code, never by the model.

What changed between versions was not the model or the quality of the prompt. It was the shape: less autonomy where it wasn't needed, isolation where it was, and enforcement moved from the prompt into code.

Worked example 2: release notes, a "no agent needed" case

A team asks for "an agent that writes release notes from merged pull requests every Friday".

Ask the question: can we draw the steps in advance? Yes.

  1. Code: fetch the PRs merged this week from the Git host's API.

  2. Code: drop PRs labelled internal or chore.

  3. One Claude call per PR, run in parallel because each PR is independent: one user-facing sentence plus a category from a fixed list, as structured output (Module 3).

  4. Code: group by category, sort, and render the Markdown template.

  5. One Claude call: a short intro paragraph from the grouped list.

  6. Human: the product manager edits and publishes.

No tools for the model, no loop, no subagents. It costs a few cents a week, and you can test every step with saved PRs. If someone insists on "an agent", ask what it would decide that this workflow can't. Usually the honest answer is nothing.

Your turn: design exercise

Month-end invoice reconciliation. Each tenant has a bank feed (CSV), invoices in the database, and supplier invoices that arrive as emailed PDFs. The system should find matches, explain mismatches and propose fixes. An accountant approves anything that gets posted.

Design: which parts are plain code, which are workflow steps, and which (if any) need an agent. What runs in parallel, what each subagent gets and returns, where the human sits, and when the loop stops.

Hints: count how many rows simple matching rules can handle before any model is involved. Then ask which single step is truly open-ended. The model answer walkthrough is in the locked lesson on the site.


Design decisions and trade-offs

DecisionOption AOption BHow to choose
ShapeWorkflow (fixed path)Agent (model picks path)Can you draw the steps in advance? Then use a workflow. Agents cost more and are harder to test.
One agent or severalOne agent, more toolsCoordinator + subagentsSplit when a part would flood the main context, can run independently, or needs a smaller tool set. Don't split small tasks; the round-trips cost more than they save.
DecompositionFixed fan-out in codeCoordinator decides at run timeFixed when the sub-tasks are always the same. Dynamic when they vary, plus a coverage checklist so nothing is skipped.
Parallel or sequentialRun subagents togetherRun them one after anotherParallel only if no subagent needs another's output. Otherwise sequence them.
Where a rule livesSystem promptCode (gate, tool layer, permissions)If breaking the rule causes damage, money loss, data exposure or anything irreversible, it goes in code.
Who sets identityThe model passes the tenant or user IDCode injects it from the sessionAlways code.
Human placementApprove every actionApprove gated actions, sample the restApprove where mistakes are costly or irreversible. Everywhere else, queue and sample, or people stop reading.
Stop conditionModel says done (end_turn)Guards: turns, budget, time, no progressBoth. The stop reason ends a normal run; guards end an abnormal one, with a report.

Anti-patterns

  • The "agent" that is a workflow. An agent loop for a task with fixed steps. Slower, costlier, flakier, and nothing gained.

  • One agent with every tool. Tool confusion, slow simple cases, and a huge blast radius.

  • Deciding "done" from the text. Parsing Claude's prose for "complete", or asking "are you finished?". Use stop_reason.

  • No guards. A loop with no turn limit, budget or timeout will eventually spin.

  • A guard that hides itself. Hitting the turn limit and returning the partial answer as if it were complete.

  • "It remembers the chat." A subagent brief that refers to "the issue above" or "the customer". The subagent has none of that.

  • Unstructured subagent results. Free text the coordinator has to guess from, with no sources and no "could not check".

  • Parallel steps that aren't independent. Two subagents running at once where one needs the other's answer. The second guesses or fails.

  • Policy in the prompt only. "Never refund over $500" as a sentence, with the refund tool fully available.

  • The model picks the tenant. tenant_id as a free input on a tool. One confused or manipulated call reads someone else's data.

  • Subagents talking to each other directly. It hides the flow and makes failures hard to trace. Route through the coordinator.

  • Rubber-stamp humans. A person asked to approve every step, with a transcript instead of a clear proposal. They stop reading.


Remember

  • Least autonomy that works: one call → workflow → agent. If you can draw the steps, it's a workflow.

  • The agent loop: Claude asks, your code runs the tool, the result goes back. Stop on stop_reason, plus guards for turns, budget, time and progress.

  • Subagents start with an empty context. Brief = goal, known facts, limits, return format.

  • Results come back structured: answer, sources, status, what couldn't be checked.

  • Parallel only when independent.

  • Prompts advise, code enforces. Money, irreversible actions, identity, tenancy and permissions live in code.

  • Put humans where mistakes are costly, and show them a proposal, not a transcript.


Facts in this module, and where to check them

FactCheckedSource
Tool loop: tool_use blocks; tool_result with matching tool_use_id, placed first in the next user message; is_error2026-11-25Handle tool calls (opens in a new tab)
The seven stop reasons listed above2026-11-25Handling stop reasons (opens in a new tab)
Workflow patterns and "start simple" guidance2026-11-25Building effective agents (opens in a new tab)
Subagents run in their own, separate context window2026-11-25Claude Code subagents (opens in a new tab)

Practice: 15 questions for this module.

↑ ↓ सार्नुहोस् · ↵ छान्नुहोस् · esc बन्द