D1 · Agentic Architecture › Cluster 4 · Multi-Agent

4.5 · Explicit State Passing

Pass all the required state — but only the required state

CONCEPT The two-sided rule

Because sub-agents are context-isolated (4.4), the coordinator must hand each one the state it needs explicitly. But there's a second edge: passing too much bloats the sub-agent's context, costs tokens, and can distract it. So the rule has two sides:

🔑 Pass the minimum required state. Missing state → the lost-state bug (the sub-agent guesses or fails). Excess state → context explosion (cost, latency, distraction). Aim for the tight middle.
Failure modeCauseSymptom
Lost stateUnder-passing — assumed the sub-agent knew itSub-agent hallucinates, asks, or produces wrong output
Context explosionOver-passing — dumped full history "to be safe"Higher tokens/cost/latency; specialist loses focus

CONCEPT How to decide what to pass

For each sub-task, ask: what facts must this specialist have to do its job well? Include those and nothing else. Typical payload: the specific inputs (a doc, a number, constraints), relevant prior results, and the acceptance criteria. Exclude: unrelated turns, other specialists' internal reasoning, and the coordinator's scratch work.

DIAGRAM The state payload

flowchart LR subgraph CTX["🟣 Coordinator context (large)"] F1["needed: budget, doc"] F2["needed: prior result"] X1["noise: chit-chat"] X2["noise: other sub-task's reasoning"] end F1 --> P["📦 explicit state payload
(minimal + complete)"] F2 --> P X1 -. excluded .-x P X2 -. excluded .-x P P -->|delegate| SUB["🔵 Sub-agent (isolated)"] classDef p fill:#e2d4f0,stroke:#764ba2,color:#3d1a5b; classDef b fill:#d1ecf1,stroke:#17a2b8,color:#0c5460; classDef pack fill:#fff9db,stroke:#b08900,color:#7a5c00; class CTX p; class SUB b; class P pack;

CODE Delegate with an explicit state payload

Build a small, structured payload of exactly what the specialist needs, then send it as the delegated task.

# Collect only the state THIS sub-task requires — complete but minimal.
state = {
    "objective": "Recommend a database for the workload below.",
    "constraints": {"budget_usd_mo": 5000, "region": "eu-west"},
    "workload": workload_summary,          # the specific input it must reason over
    "prior_findings": research_result,     # a relevant earlier result — passed in, not assumed
    # NOTE: no coordinator chit-chat, no other specialists' scratch work.
}

import json
task = f"Task:\n{json.dumps(state, indent=2)}\n\nReturn a single recommendation with a one-line reason."

specialist = client.messages.create(
    model="claude-sonnet-4-6", max_tokens=1024,
    system="You are a database-selection specialist. Use ONLY the state provided.",
    messages=[{"role": "user", "content": task}],   # the explicit, self-contained payload
)
Structuring state as JSON makes "what did I actually pass?" auditable — a direct defense against the lost-state bug, and it keeps the payload tight.

TRADE-OFFS Completeness vs. minimality

✅ Lean, complete payload

  • Sub-agent has exactly what it needs
  • Lower tokens, cost, and latency
  • Specialist stays focused on its task

⚠️ Getting it wrong

  • Too little → lost-state bug, wrong output
  • Too much → context explosion, distraction
  • "Just pass everything" is not the safe default

EXAM TRAPS

Trap: The lost-state bug — assuming the sub-agent "knows" a fact from the coordinator's history. → It's isolated (4.4). If it isn't in the delegated payload, the sub-agent never saw it.
Trap: "To be safe, pass the entire conversation." → That causes context explosion: cost, latency, and distraction. Pass the minimum required, not everything.
Trap: Passing another specialist's internal reasoning instead of its result. → Sub-agents need each other's outputs, not their scratch work. Keep the payload to what's actually required.

PRACTICE

Q1 · A drafting sub-agent produces off-topic copy. The coordinator "told" it the brief earlier in its own turn. Diagnosis?

Lost-state bug. The brief lived in the coordinator's context, which the isolated sub-agent can't see. Fix: put the brief into the delegated message payload.

Q2 · A team fixes lost-state by piping the full 40-turn history into every sub-agent. New problem?

Context explosion. Tokens, cost, and latency spike, and specialists lose focus. Pass only the minimum required state per sub-task, not the whole transcript.

Q3 · Why prefer a structured (e.g. JSON) state payload over free-form prose?

It makes exactly what you passed auditable and keeps the payload tight — easy to see if a required field is missing (lost state) or if you're over-including (explosion).