CONCEPT Three failure modes of agentic systems
An agent is a loop of network calls to a stateless POST /v1/messages, often
fanned out across sub-agents and tools. That structure creates three recurring failure modes. The architect's
job is to name the failure mode, then apply its matching structural fix — not to sprinkle
try/except and hope.
| Failure mode | What goes wrong | Root cause | Structural fix |
|---|---|---|---|
| Cascade | Agent 1 fails → the failure propagates into agent 2 and 3, taking the whole system down | No isolation between dependent steps; every call keeps hitting a dead dependency | Circuit breaker — stop calling the failing component (see 6.2) |
| Lost state | A sub-agent produces garbage because it lacks the context the parent had | The API is stateless — nothing is remembered between calls unless you pass it | Pass state explicitly into every sub-agent's messages |
| Timeout chain | Sequential agents each add latency until the whole request times out | Independent work is run serially; no per-step deadline | Parallelise independents + set per-step timeouts (see 6.7) |
/v1/messages is stateless, "lost state" is the
default behaviour, not an exception. A sub-agent knows only what you put in its messages
array. If the parent gathered facts and didn't forward them, they're gone.DIAGRAM Failure → fix map
agent1 fails → 2,3 fail"] C2["Lost state
sub-agent lacks context"] C3["Timeout chain
serial latency piles up"] end subgraph X["🛠️ Structural fixes"] X1["Circuit breaker
stop the failing call"] X2["Pass state
explicitly forward context"] X3["Parallelise + timeouts
bound each step"] end C1 --> X1 C2 --> X2 C3 --> X3 classDef bad fill:#f8d7da,stroke:#dc3545,color:#721c24; classDef fix fill:#d4edda,stroke:#28a745,color:#155724; class C1,C2,C3 bad; class X1,X2,X3 fix;
CONCEPT The recovery ladder
When a step fails despite the structural fixes, don't give up or crash — climb the recovery ladder. Take the cheapest, most local action first; escalate only when it doesn't work.
| Rung | Action | Use when |
|---|---|---|
| 1 · Retry | Re-issue the same call, with backoff | Transient errors — 429, 5xx, 529, connection blips (see 6.3) |
| 2 · Fallback | Try an alternate tool, skip the step, or take a degraded path | The primary path is durably broken but the task can still partly succeed (see 6.4) |
| 3 · Escalate | Hand off to a human | Repeated failure, low confidence, or policy (e.g. payments) (see 6.5) |
tool_result "is_error": true
so the model can adapt — pick another tool or explain the limitation — instead of hallucinating
a result.CODE Naming the mode, then applying the fix
A parent agent orchestrating two sub-agents. The comments mark where each failure mode lives and which fix defuses it.
# Stateless API: a sub-agent knows ONLY what we pass in its messages. import anthropic, concurrent.futures as cf client = anthropic.Anthropic() def sub_agent(role, context): # FIX for LOST STATE: forward the parent's context explicitly. return client.messages.create( model="claude-sonnet-4-6", max_tokens=1024, system=role, messages=[{"role": "user", "content": context}], # state passed in ) facts = gather_facts() # parent's context # FIX for TIMEOUT CHAIN: run INDEPENDENT sub-agents in parallel, not serially. with cf.ThreadPoolExecutor() as ex: f1 = ex.submit(sub_agent, "You are a legal reviewer.", facts) f2 = ex.submit(sub_agent, "You are a finance reviewer.", facts) legal = f1.result(timeout=60) # per-step deadline finance = f2.result(timeout=60)
EXAM TRAPS
PRACTICE
Q1 · A pipeline of five sequential sub-agents intermittently exceeds the client's latency budget. First fix?
Identify which steps are independent and run those in parallel, and add a per-step timeout so one slow hop can't consume the whole budget. This is the timeout-chain fix. Only if the steps are genuinely dependent do you optimise each hop individually.
Q2 · When one downstream tool starts erroring, every request in the system slows and eventually fails. Which mode, which fix?
Cascade. Wrap the failing tool in a circuit breaker so that once its error rate crosses a threshold you stop calling it and fail fast (or fall back), instead of every request piling onto the dead dependency.
Q3 · A summariser sub-agent keeps summarising the wrong document. Root cause?
Lost state. The stateless API means the sub-agent only sees the messages
you sent. It never received the right document/context. Fix by explicitly passing the selected document into
the sub-agent's request — not by prompt-tuning.