D1 · Agentic Architecture › Cluster 6 · Reliability

6.1 · Failure Modes

Cascade · lost state · timeout chain — and their fixes

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 modeWhat goes wrongRoot causeStructural fix
CascadeAgent 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 stateA 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 chainSequential 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)
🔑 Because /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

flowchart LR subgraph F["⚠️ Failure modes"] C1["Cascade
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.

RungActionUse when
1 · RetryRe-issue the same call, with backoffTransient errors — 429, 5xx, 529, connection blips (see 6.3)
2 · FallbackTry an alternate tool, skip the step, or take a degraded pathThe primary path is durably broken but the task can still partly succeed (see 6.4)
3 · EscalateHand off to a humanRepeated failure, low confidence, or policy (e.g. payments) (see 6.5)
Signal a failed tool back to Claude with 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)
⚠️ Parallelising only works for independent steps. If finance needs legal's output, they're a real chain — bound each hop with its own timeout instead (see 6.7).

EXAM TRAPS

Trap: "Agent 2 crashes whenever agent 1's dependency is down." → That's a cascade; the fix is a circuit breaker (stop calling the dead dependency), not more retries — retries against a dead component just cascade faster.
Trap: "The sub-agent gives irrelevant answers." → Suspect lost state first. The API is stateless; the sub-agent only sees what you passed. The fix is forwarding context, not a bigger model.
Trap: "Three agents run one after another and the request times out." → Timeout chain. If the steps are independent, parallelise; either way set per-step timeouts. A single global timeout hides which hop is slow.
Trap: Treating retry as the answer to everything. → Retry is only rung 1, for transient faults. A durable failure needs fallback or escalation, not an infinite retry loop.

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.