Workflow versus agent, orchestrator and subagents, loop limits in code, durable execution, memory and compaction, and tool scaling for production Claude agents.
A demo agent runs once, on a good day, with a developer watching. A production agent runs thousands of times, on bad days, and nobody is watching. This module is about the architecture decisions that separate the two: when to use an agent at all, how to split work between specialists, how to stop a loop, how to survive a crash halfway through, and how to remember things without leaking them.
One theme repeats in every section and in most exam scenarios: anything that must always hold belongs in code, not in a prompt. A prompt is a request the model will usually honour. A loop counter, a state machine, a schema check or a permission check is a guarantee.
Anthropic-specific details below (stop reasons, the tool-use loop, SDK options) come from the official pages listed under Where to verify. Where a detail varies by version, the lesson says so and tells you to check the docs.
1.1 Workflow or agent?
Principle. If you can write down the steps in advance, build a workflow: your code decides the order and calls the model for the steps that need language understanding. Use an agent, where the model decides the next step, only for parts of the problem where the path really is dynamic. Autonomy costs you predictability, latency and money, so add it only where it earns its place.
Question
Points to a workflow
Points to an agent
Is the sequence of steps known before the request arrives?
Yes
No, it depends on what is found along the way
Does a wrong order cause harm or a compliance problem?
Yes
No
Can you enumerate the branches?
Yes
The branches are open-ended
Do you need a repeatable audit trail?
Yes
A looser trace is acceptable
Figure 1. Workflow, hybrid or agent: three questions
flowchart TD
accTitle: Choosing between a workflow, a hybrid and an agent
accDescr: Start by asking whether the order of steps is known in advance. If it is, build a workflow. If it is not, ask whether a wrong order causes harm or you need an audit trail. If yes, build a hybrid with a fixed workflow around one bounded agent step. If no, use an agent with hard limits.
S(["New process to automate"]) --> Q1{"Is the order of steps known in advance?"}
Q1 -->|yes| W["Workflow: your code sets the order"]
Q1 -->|no| Q2{"Does a wrong order cause harm, or do you need an audit trail?"}
Q2 -->|yes| H["Hybrid: fixed workflow around one bounded agent step"]
Q2 -->|no| A["Agent with hard limits on turns and cost"]
How to read this: start at the top and follow the answers down. Only the bottom-right box lets the model choose the path on its own, and even that box carries limits.
Mechanism. Most production systems are hybrids. A fixed workflow handles intake, validation and the irreversible final step. One bounded agent step sits inside it for the open-ended part, such as investigating an ambiguous ticket. The agent's output then goes back through deterministic validation before anything is committed.
Figure 2. A hybrid: one bounded agent step inside a fixed workflow
How to read this: the solid path is the normal run. The agent step is the only place the model chooses what to do, and its output must pass validation before the final step. The red dashed arrow is the way out when validation fails.
TIP
Picture it: A restaurant kitchen has a recipe for every dish on the menu, and the line cooks follow it in the same order every time. Only when a guest asks what can be made without nuts tonight does the head chef improvise. A good production system has the same shape: recipes for the known parts, one improvising chef for the open question, and a pass where someone checks the plate before it leaves. The comparison stops at accountability: a chef answers for the plate, but a model answers only through the checks you build around it.
Example. Lanternworks, a fictional freight company, processes customs documents. Steps one to four (parse, classify, check against the tariff table, draft the filing) are always the same, so they are a workflow of four model calls with typed outputs. Only "resolve a mismatch between the invoice and the packing list" varies enough to justify an agent, and it runs with a tool list limited to read-only lookups and a hard turn limit.
Exam angle. A scenario describes a process with a fixed, auditable order and asks how to build it. The best answer is a workflow with the model inside steps. Common trap: a single autonomous agent with "follow these steps in order" in its prompt. It works in testing and skips a step under pressure, and the exam expects you to see that order is a property of the system, not of a request.
1.2 Orchestrator and specialist subagents
Principle. When a task has distinct parts that need different context or different tools, split them: one orchestrator plans and delegates, and each specialist subagent does one job with only the context and tools that job needs.
Mechanism. Scoping is the point. A specialist that sees only what it needs is cheaper, less distracted and easier to secure. In the Python Agent SDK, a subagent definition carries its own description, prompt, tools list, model, and optional limits such as maxTurns (these field names are in the SDK source on GitHub; check the Agent SDK docs for the current set). Giving each subagent a short tool list is least privilege applied to agents.
The handoff between orchestrator and specialist should be structured, not a pasted transcript:
The specialist returns a typed result (findings, evidence ids, a confidence field, an escalate flag). The orchestrator validates it against the schema before using it. If a specialist returns free text, a downstream step will eventually parse it wrongly.
Figure 3. An orchestrator with specialists that each work in their own context
How to read this: each arrow carries a small typed task, not a pasted transcript, and each specialist sees only its own box. Each specialist sends back a typed result (not drawn), which the orchestrator validates before use.
TIP
Picture it: A hospital emergency desk does not send every patient to one all-purpose doctor. A triage nurse writes a short structured note and sends the patient to the right specialist, who sees only what that case needs. The findings come back on a form, and the nurse checks the form is complete before acting on it. The comparison has one gap: a hospital specialist is trusted by licence, while a subagent's answer stays untrusted input until your code has validated it.
NOTE
Treat the output of every subagent as untrusted input to the orchestrator, exactly like a tool result. A subagent that read a poisoned web page can pass the poison upward.
Exam angle. A scenario shows a single agent with forty tools and a long context that picks wrong tools and drifts. The strong answer splits into an orchestrator and scoped specialists with structured handoffs. Common trap: "use a bigger model". Scope, not capability, is the problem.
1.3 Loop control belongs in code
Principle. An agent loop needs limits that the model cannot talk its way past: a maximum number of turns, a budget (tokens, tool calls or money), explicit termination conditions, and a defined behaviour when a limit is hit. That behaviour is normally escalation to a person or a safe stop, not "try again".
Mechanism. The Messages API tool-use loop is yours to bound. Each response carries a stop_reason. The documented values are end_turn, max_tokens, stop_sequence, tool_use, pause_turn, refusal and model_context_window_exceeded. For tool_use, you run the tool and reply with a user message that contains only tool_result blocks. For pause_turn (a server-tool loop reached its iteration limit), you send the assistant content back unchanged to continue. Everything else ends the loop, and your code decides what that means.
Figure 4. The loop with its exits
flowchart TD
accTitle: Agent loop with limits and exits
accDescr: The run checks whether the turn limit is reached before each model call. If it is, the run escalates to a person. Otherwise the model is called and the stop reason decides what happens. End of turn means done. A pause turn goes back to the loop. A tool use checks the tool budget, and if budget is left the tool runs and the result goes back to the loop, otherwise the run escalates. Any other stop reason escalates.
S(["Start run"]) --> N{"Turn limit reached?"}
N -->|yes| X(["Escalate to a person"])
N -->|no| C["Call the model"]
C --> R{"stop_reason?"}
R -->|end_turn| D(["Done"])
R -->|pause_turn| N
R -->|tool_use| B{"Tool budget left?"}
R -->|anything else| X
B -->|no| X
B -->|yes| T["Run tool, send tool_result"]
T --> N
How to read this: follow any path and count the exits. Every loop-back goes through the turn-limit diamond at the top, so the counter always gets its say, and every limit ends at the same escalation box.
TIP
Picture it: A fuse box does not ask the toaster to please use less power. When the current goes over the limit the circuit opens, whatever the toaster would prefer. Turn limits and budgets in your loop work the same way: they trip on a count, not on the model's good intentions. The difference is that a tripped fuse just goes dark, while your loop should hand over to a person and say why it stopped.
The Agent SDK exposes the same idea as options. The Python README shows ClaudeAgentOptions(max_turns=...), a permission_mode, allowed_tools and disallowed_tools, and hooks such as PreToolUse that can return a deny decision. Note that allowed_tools is an auto-approve list, not a removal of tools: unlisted tools still fall through to the permission mode. The SDK also documents a way to cap spend, and its result message reports which limit ended the run; confirm the option and result names in the Agent SDK docs for your version.
Exam angle. An agent occasionally loops for dozens of turns on an ambiguous ticket and the prompt already says "be efficient". The answer sets hard limits in the loop and handles the limit-hit result in application code. Common trap: strengthening the prompt wording. A prompt reduces the chance of a long loop; only a counter prevents one.
1.4 Durable execution and checkpoints
Principle. A long task will be interrupted: a deploy, a crash, a rate limit, a human who takes two days to approve. Design so that the run resumes from the last completed step instead of restarting, and so that resuming never repeats a side effect.
Mechanism. Four rules.
Checkpoint at logical step boundaries, after a step's result is validated and its side effects are recorded, not after every token or every tool call.
Make side effects idempotent. Give each external write a key derived from the run and step (run_7f3:pay:1) so a retried step cannot pay twice.
Keep state in your own store, in a typed structure, not only inside the conversation.
Never put secrets in saved state. Save a reference to a credential, not the credential. Saved state gets logged, copied and replayed.
On resume, the orchestrator reads this record, skips completed steps, and for any step with a recorded side effect checks its status before acting. A workflow engine (a job queue with step state, or a durable-execution library) gives you this. A prompt that says "remember where you were" does not.
Figure 5. Crash and resume without paying twice
sequenceDiagram
accTitle: Resuming a run after a crash with an idempotency key
accDescr: The orchestrator saves each completed step to the checkpoint store, then sends a payment request carrying an idempotency key. The process crashes before the answer arrives. A new process loads the run record, sees the payment is pending with its key, asks the payment system for the status of that key, learns it was already received, and records the step as done instead of paying again.
autonumber
participant O as Orchestrator
participant S as Checkpoint store
participant P as Payment system
O->>S: save step fetch_invoice done
O->>S: save step extract_lines done
O->>P: submit payment, key run_7f3:pay:1
Note over O: process crashes before the answer arrives
O->>S: new process loads run_7f3
S-->>O: completed steps, payment pending with key
O->>P: status of key run_7f3:pay:1?
P-->>O: already received
O->>S: save step submit_payment_request done
How to read this: the numbers run top to bottom. The line to watch is number 6, where the new process asks about the key instead of sending a second payment.
NOTE
On call, 3 a.m.: Priya Nair runs the invoice agent at Kestrel Freight, an invented logistics company. A deploy restarts the service while a twelve-step run is on step nine, and the old design starts over from step one. The vendor receives two payment requests for the same invoice. After the fix, every run saves its step list after each validated step, and the payment call carries a key built from the run and the step. The next restart resumes at step nine, finds the key already recorded as pending, and checks its status instead of paying again. Invented example.
Exam angle. "A twelve-step process fails at step nine and restarts from step one, creating duplicate records." The answer is checkpointing plus idempotency keys. Common trap: "retry the whole run with a longer timeout". That repeats steps one to eight and their side effects.
1.5 Memory and context compaction
Principle. "Memory" is three different things, and conflating them causes both quality bugs and privacy bugs.
Kind
What it holds
Lifetime
Typical home
Conversation history
The messages of this session
One session
The messages array
Task state
Structured facts about this run (ids, decisions, step)
One task
Your own store, typed
Durable facts
Extracted, reviewed facts about a user or account
Months
A database with retention rules
Anthropic documents a client-side memory tool for storing and retrieving information across conversations in files you control, which means retention, access control and deletion are your responsibility.
Privacy design. For each durable fact decide the scope (per user, per tenant), who and what can read it, how long it lives, and whether it contains personal data. A soft delete (a deleted flag) may not satisfy an erasure request if the value still sits in backups, search indexes or derived summaries. Design deletion to remove the value and its copies.
Compaction. When context grows, you summarise older turns. A free-text summary loses exact values, such as an amount, an id, or a date, or rewrites them. Keep those in the structured task state and rebuild the prompt from state plus a short summary. The model gets the narrative from the summary and the facts from the state.
Figure 6. Rebuilding the prompt from state, summary and recent turns
How to read this: three sources flow into one piece of your code. The green box is the only source the prompt treats as exact, so amounts, ids and dates live there and never only in the summary.
NOTE
On call, 3 a.m.: Maya Okafor at Birchfield Telecom, an invented company, watches a support agent offer a 14.50 EUR refund and then, ninety minutes later in the same chat, promise 15 EUR. The long session had been summarised, and the summary kept the words "agreed refund" but rounded the amount. The team stops asking the summary to carry numbers. Amounts, ids and dates move into a typed task state that goes into every prompt as authoritative, and the summary tells only the story of the conversation. Invented example.
Exam angle. A long support session starts quoting the wrong refund amount after the history was summarised. The answer keeps exact values in structured state outside the summary. Common trap: "increase the summary length". A longer paraphrase still paraphrases.
1.6 Enforcing order and avoiding circular calls
Runbook order. If a procedure must run in a fixed sequence (verify identity, then check eligibility, then issue the credit), implement it as a state machine or workflow engine whose transitions are code. The model fills in content within a step; it cannot skip to step three. Prompts that list "step 1, step 2, step 3" are a description of the desired order, not an enforcement of it.
Circular agent calls. If agent A can call agent B and B can call A, you can get a loop that no single agent's turn limit sees. The structural fix is a single coordinator or a strict hierarchy where calls only go downward. A depth limit helps contain damage but is a weaker fix: it stops the loop after waste has occurred and does not remove the cycle.
Approach
Prevents the cycle?
Notes
Single coordinator, specialists never call each other
Yes
Simplest to reason about and to trace
Strict hierarchy, calls only downward
Yes
Needs a clear owner at each level
Depth or hop limit
No, it caps it
Useful as a backstop
"Do not call back" in the prompt
No
A request, not a control
NOTE
On call, 3 a.m.: Tomas Rivera at Harbourline Insurance, an invented company, finds a few hundred tickets bouncing between a triage agent and a billing agent. Each decides the other is the right owner, and neither turn limit ever trips because each handoff starts a fresh count. A prompt line saying "never send a ticket back" helps for a week. The real fix makes triage the only coordinator: billing can return a result but cannot call triage, and a hop counter on the ticket stops anything unexpected after three hops. Invented example.
Exam angle. Two agents hand a ticket back and forth until a timeout. The best answer is a coordinator or hierarchy so cycles cannot occur, with a hop counter as a backstop. Common trap: only adding a depth limit, or only a prompt rule.
1.7 Tools at scale, async work and parallelism
Dozens of tools. Every tool definition is sent as input tokens on every request, and a very long tool list also makes selection harder. Options, in rough order: split by specialist (1.2) so each agent sees a few tools; load tools dynamically by task; or use Anthropic's tool search tool, documented as a way to work with large numbers of tools by discovering and loading them on demand. Check the tool search page for current availability and any beta requirements.
Long-running tools. A tool that takes minutes should not block the loop on a synchronous call. Start the job, return a job id immediately, and deliver the result by callback or a status check that your orchestrator handles as a checkpointed step (1.4). Hold no model call open while you wait.
Parallel steps. Independent steps (fetch three unrelated records) can run together; the API supports multiple tool calls in one turn, and tool_choice accepts disable_parallel_tool_use when you need at most one call per turn. Steps with data dependencies (use the customer id returned by step one) must run in order. Parallelise by dependency graph, not by habit.
Exam angle. A scenario has a report that calls six independent lookups one after another and takes too long, while a seventh step needs all six results. The answer runs the six in parallel and the seventh after. Common trap: running all seven in parallel, which feeds the final step incomplete data.
1.8 Human-in-the-loop and approval flows
Principle. A person in the loop is a control placed at the points where a mistake is expensive or cannot be undone. It is not a general comfort blanket. Ask for approval on everything and people start approving without reading, which is worse than having no gate.
Where to put it. Decide by reversibility and blast radius, not by how nervous the team feels.
Placement
Use it when
Weakness
Plan approval, before the run starts
The plan is short and the cost of a wrong plan is high
The agent may deviate from the plan later
Action gate, before one irreversible step
Payments, deletions, external messages, production changes
Needs a precise record of what is being approved
After-the-fact review with undo
Low-impact, reversible edits
Useless if the action cannot be reversed
Mechanism. The gate is code. The agent proposes a structured action, the run checkpoints in an awaiting_approval state and holds no model call open, and a person decides through your application, which records who and when.
On approval, the executor runs exactly the approved arguments, after checking that they are unchanged and the approval has not expired. The model cannot approve its own action, and a second "approver" model is not a substitute for a person on an irreversible step. Show the reviewer the evidence, not only the conclusion.
Figure 7. An approval gate that waits without holding a model call
How to read this: follow the top row to see the proposal reach a person, then the bottom row to see the executor run only what was approved. The red dashed arrow is the path where nothing runs.
TIP
Picture it: A shop cashier can look up any order freely, but a refund over the counter limit needs a supervisor to sign the slip. The supervisor reads the evidence on the slip, and the till pays only the amount written on it. A supervisor asked to sign every single receipt would soon sign without reading, which is why the second key is kept for the moves that cannot be undone.
NOTE
Exam angle: an agent takes an irreversible action without anyone seeing it, and the team proposes asking the model "are you sure?" first. The answer is a code-enforced gate on that action, with a checkpointed wait and the approved payload bound to what executes. Common trap: approving every tool call, which causes approval fatigue and lets the one dangerous call through unread.
1.9 Parallel dispatch, context isolation and failures between agents
Principle. An orchestrator can dispatch independent subtasks to several subagents at once. Each subagent works in its own context, and only its result comes back. That isolation keeps the orchestrator's context small and keeps one subagent's noise, or poison, away from the others. The cost is that a subagent knows only what you hand it.
Communication. Agents talk through the orchestrator or a shared store using typed messages (section 1.2), never through open-ended chat between specialists (section 1.6).
Failures. Fan-out creates partial failure, which a single agent never has. Decide the policy for each subtask in advance.
Situation
Policy
Subagent times out or exceeds its budget
Stop it, record the cause, apply the subtask's policy below
Result fails schema validation
Retry once with the validation error, then treat as failed
Subtask is required
The run escalates or fails, because a partial answer would mislead
Subtask is optional
Continue, and state in the final output which part is missing
Two results contradict each other
Resolve by a written rule such as source priority, or escalate. Do not let the orchestrator average them
Retries must respect section 1.4: a subagent that already caused a side effect needs an idempotency key before you re-run it.
TIP
Picture it: A newsroom editor sends five reporters to cover five parts of one story. Each reporter works from their own notes and files a short piece, and they do not read each other's notebooks. If one misses the deadline, a good editor has already decided whether the story can run without that part, and says so in print instead of quietly filling the gap. The newsroom is looser than your system should be: reporters may chat in the corridor, while agents talk only through the orchestrator (section 1.6).
results = run_in_parallel(subtasks, timeout_s=90) # each isolated, each budgetedfor task, res inzip(subtasks, results):
if res.failed and task.required:
return escalate(f"required subtask failed: {task.name}", res.error)
if res.failed:
gaps.append(task.name) # reported, never silently dropped
Exam angle. Four of five research subagents return and one times out. The strong answer applies the per-subtask policy and discloses the gap. Common trap: the orchestrator quietly writes a confident answer as if all five returned.
1.10 Surviving a model version change
Principle. A model identifier is a dependency, and dependencies change: you upgrade, or a version is retired. Design so that a version change is a managed release, not an accident in the middle of long-running work.
Mechanism.
Pin the model identifier per run, record it in the checkpoint, and change it through configuration. An alias that moves under you changes behaviour with no release record. Check the model documentation for the current naming and the retirement schedule.
Keep authoritative state in your own typed store (sections 1.4 and 1.5), not only in a transcript written by the old model. State survives a version change. A transcript carries the old model's phrasing and decisions, and a new model may read them differently.
Decide what happens to in-flight runs. Either finish them on the version they started with, or resume at a checkpoint boundary on the new version after replaying them in a test. Do not switch a run mid-step.
Expect a cold cache. Cached prefixes belong to the model they were created for, so the first requests after a switch are slower and cost more. Plan for it in the cost forecast.
Re-run your evaluation suite on the new version before it takes traffic. Prompts tuned to one model may need changes for another, and loop limits, tool-call patterns and output length can shift.
Layer
Survives a version change?
Why
Typed task state, checkpoints
Yes
Owned by your code
Durable facts in your store
Yes
Same
Summaries written by the old model
Partly
Re-check exact values against state
Cached prefixes
No
Tied to the model
Exam angle. A fleet of week-long runs must move to a newer model while many are in flight. The best answer pins versions per run, resumes from checkpoints, gates the new version behind an evaluation run and a staged rollout. Common trap: relying on a floating alias and finding out from user complaints.
1.11 Evolving a running system, and setting team standards
Principle. The first architecture is a guess. Once a system is in production, its own data tells you whether to move it toward more workflow (more predictable and cheaper) or more agent (more flexible).
Reading the data. Look at the distribution of real runs, not the average.
Signal in production data
Suggests
Most runs follow the same sequence of tool calls
Promote that path to a workflow, and keep the agent for the tail
Cost and latency dominated by a few exploratory steps
Bound or replace those steps
A rigid workflow escalates or fails on a large share of cases
Give that step a bounded agent
Quality varies mainly by case type
Route by type, using different architectures per type
As an invented example, if 17,000 of 20,000 runs follow one four-step path, that path is a workflow candidate: it removes loop cost and variance for 85% of traffic, and the other 3,000 keep the agent. Test the change with a canary and per-segment comparison (module 7, section 7.6) before you widen it. The reverse also happens: a workflow that keeps hitting uncovered branches should gain an agent step where the branches are open-ended.
Standards. A team that lets every project pick its own harness, framework and patterns pays for it in on-call confusion, duplicated bugs and unreviewable code. Agree a small set: one agent harness or SDK, one orchestration pattern per problem class (workflow, orchestrator plus specialists), shared loop-limit, checkpoint and handoff libraries, and an exception process with a named owner. Judge a framework by how it exposes the controls from sections 1.3 to 1.9 (limits, checkpoints, gates, tracing), not by demos. Standardise the contract, not every line of code.
Exam angle. A running agent shows one dominant path. The answer converts it to a workflow with an agent for the exceptions. Common trap: rewriting the system to a different architecture wholesale because one segment struggles.
1.12 Context editing, compaction and persistent memory
Principle. Three techniques manage context, and each fits a different problem. Mixing them up wastes tokens or loses facts.
Technique
What it does
What it can lose
Best for
Context editing
Clears stale content, usually old tool results, from the working context while the conversation continues
The cleared content, so the agent must re-fetch it if needed
Long tool-heavy runs where old bulky results no longer matter
Compaction
Replaces older turns with a summary
Exact values and nuance (section 1.5)
Long conversations whose narrative must continue
Persistent memory
Stores facts outside the context for later sessions or later in the same task
Nothing, if written well, but it needs retention and deletion design
Facts that must outlive the window
Anthropic documents server-side context editing and a memory tool; check the current documentation for availability, beta status and configuration names.
Choosing. Start from what is filling the window. If it is raw tool output from forty turns ago (search results, logs, file contents), clear those: the conclusions already sit in the conversation or in state. If it is the dialogue itself, compact, and keep exact values in structured state. If the agent must remember something tomorrow, write it to memory.
Before clearing a tool result, make sure anything the run needs from it is already recorded in state. Keep the most recent results, and for pinned or critical content exclude it from clearing. A cleared result is gone, and the agent only knows that a call happened.
TIP
Picture it: The context window is your desk. Context editing is clearing last week's printouts that you have already read, compaction is writing a one-page recap of a long meeting, and persistent memory is the filing cabinet for what you will need next month. Shredding a printout is safe only if you first copied the figures you need into your notebook, and the notebook is your task state.
Exam angle. An agent's window fills with large old log dumps while its reasoning is sound. The answer is clearing stale tool results. Common trap: summarising the entire conversation, which also rewrites the exact values that should have been kept.
1.13 Cache-safe instruction changes and tool search
Cache-safe changes. Prompt caching matches an exact prefix, and the prefix is built in the order tools, then system prompt, then messages. A change at any point invalidates the cache from that point onward. That has a practical consequence for mid-conversation changes.
You want to
Cache effect
Better approach
Edit the system prompt after turn 10
Everything after the system prompt is no longer matched
Append the new instruction as a message in the next turn
Add or remove a tool mid-run
The whole prefix is invalidated
Keep the tool list stable for the run
Put a timestamp or request id at the top of the system prompt
Misses on every request
Move volatile data to the end, in the messages
Remove old tool results every turn
Misses each time
Clear in larger, less frequent batches
State the new rule clearly in the new message, for example "From this point, refunds above 50 EUR need approval", and keep your durable policy in code. Check the caching documentation for exactly which changes invalidate which levels.
Tool search. A large catalogue costs input tokens on every request and degrades selection (section 1.7). Anthropic's tool search tool lets the model discover tools on demand, so only the definitions it finds are loaded. Apply it with judgement.
Keep a small always-loaded core for tools used in most runs, and defer the long tail.
Write names and descriptions so that search finds them: consistent verbs, domain prefixes, a plain description of when to use the tool.
Treat discovery as retrieval. A tool that is never found is a tool the agent cannot use, so test whether the right tool is found for realistic tasks.
Check the documentation for result limits, availability and interaction with caching.
Exam angle. A team edits the system prompt every few turns to add rules, and costs rise while latency worsens. The answer is to keep the prefix stable and append changes as messages. Common trap: reaching for a larger context window, when the cache misses are the cause.
IMPORTANT
Remember this:
If something must always hold, build it into code. A prompt only asks.
Known order means a workflow. An open-ended step gets a bounded agent inside that workflow.
Turn limits, checkpoints and idempotency keys make a run safe to stop and restart.
Keep exact values in typed state, and let summaries tell only the story.
Put a person in front of the irreversible step, bound to the exact action.
M1 Checkpoint
You should be able to:
Decide between a workflow, an agent and a hybrid for a described process, and justify it with predictability and risk.
Design an orchestrator and scoped specialists with a structured, schema-validated handoff.
Write an agent loop whose turn, tool and budget limits are enforced in code, with an escalation path for each stop_reason you do not handle.
Specify a checkpoint record with idempotency keys and secret references, and explain how a run resumes.
Separate conversation history, task state and durable facts, and design retention, scope and erasure for the last.
Keep exact values safe through context compaction by holding them in structured state.
Remove circular agent calls structurally, and enforce a runbook order with a workflow engine.
Choose a scaling approach for many tools, a long-running tool and a mix of independent and dependent steps.
Place human approval gates by reversibility and blast radius, and implement them as checkpointed, code-enforced waits bound to the exact action.
Dispatch subagents in parallel with isolated contexts, and set per-subtask policies for timeouts, invalid results, missing results and contradictions.
Plan a model version change: pinned identifiers, state in your own store, in-flight run handling, a cold cache and re-evaluation.
Use production run data to decide whether to move a system toward workflow or agent, and define team standards for harness, framework and patterns.
Choose between context editing, compaction and persistent memory based on what is filling the context.
Change instructions mid-conversation without breaking the cache, and apply tool search with a small always-loaded core.
The Agent SDK documentation on the Claude Code docs site covers the full option list and result types; check it for the names that apply to the SDK version you use.
Enroll to keep reading
Lesson 2 of 10 · Claude Certified Developer — Professional
Workflow versus agent, orchestrator and subagents, loop limits in code, durable execution, memory and compaction, and tool scaling for production Claude agents.
In the rest of this lesson
1.5 Memory and context compaction
1.6 Enforcing order and avoiding circular calls
1.7 Tools at scale, async work and parallelism
1.8 Human-in-the-loop and approval flows
1.9 Parallel dispatch, context isolation and failures between agents
1.10 Surviving a model version change
Enrolling is free. It unlocks every lesson in Claude Certified Developer — Professional, tracks your progress across devices and keeps your quiz scores. The newsletter is optional.
The domains, the 3 universal rules, core concepts, and exam-day shortcuts — one page. Enter your email and it's yours, plus my weekly AI-architecture notes.
No spam. Unsubscribe any time.
Scaled AI Weekly
Enjoyed this? Get more like it every Monday.
Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.
Get new articles by email
Free. We email a confirmation link first, and you can unsubscribe from any email.