CONCEPT Isolation is the whole point
A sub-agent is context-isolated: it runs its own model loop with its own context window and does not see the coordinator's conversation history. It knows only what you put in the message you send it, plus its own system prompt. This is a feature — it keeps each sub-task focused and keeps the coordinator's growing context out of the specialist — but it's also the single most common source of bugs: people assume the sub-agent "just knows" things it was never told.
| What crosses into a sub-agent? | Visible to sub-agent? |
|---|---|
| The delegated task message you send it | ✅ Yes — this is all it gets |
| The sub-agent's own system prompt | ✅ Yes |
| The coordinator's conversation history | ❌ No — isolated |
| Other sub-agents' contexts / results | ❌ No — unless you pass them in |
| Facts the user told the coordinator earlier | ❌ No — unless restated |
CONCEPT Why isolate at all?
- Focus: a specialist reasoning over only its task avoids distraction and drift.
- Context budget: the coordinator's history can be huge; not replaying it into every sub-agent saves tokens and keeps each window clean.
- Independence: isolated sub-agents can run in parallel without interfering (see 4.6).
DIAGRAM Separate context windows
user msgs · prior tool results · plan"] end subgraph SUB1["🔵 Sub-agent A context (isolated)"] TA["only: system prompt +
the task you sent"] end subgraph SUB2["🔵 Sub-agent B context (isolated)"] TB["only: system prompt +
the task you sent"] end H -->|"delegate: copy needed state"| TA H -->|"delegate: copy needed state"| TB TA -. "cannot see coordinator history" .-x H TB -. "cannot see sub-agent A" .-x TA classDef p fill:#e2d4f0,stroke:#764ba2,color:#3d1a5b; classDef b fill:#d1ecf1,stroke:#17a2b8,color:#0c5460; class H p; class TA b; class TB b;
CODE Isolation, made concrete
The sub-agent's messages is a brand-new list. Nothing from the coordinator leaks in — only what
you write into it.
# WRONG assumption: "the sub-agent saw the user say the budget is $5k earlier." # It did NOT. Its context is only what's in THIS messages list + system. sub = client.messages.create( model="claude-sonnet-4-6", max_tokens=1024, system="You are a pricing specialist.", # its only standing context messages=[{"role": "user", "content": "Recommend a plan."}], # budget NEVER mentioned → it can't know it ) # RIGHT: restate the needed fact explicitly in the delegated task. sub = client.messages.create( model="claude-sonnet-4-6", max_tokens=1024, system="You are a pricing specialist.", messages=[{"role": "user", "content": "Budget is $5,000/mo. Recommend a plan within it."}], )
EXAM TRAPS
PRACTICE
Q1 · A coordinator delegates "summarize the doc" to a sub-agent but never includes the doc. What happens?
The sub-agent has nothing to summarize — it can't see the coordinator's context where the doc might live. The doc text must be passed into the delegated message. This is the classic lost-state bug (4.5).
Q2 · Why is context isolation actually helpful, not just a constraint?
It keeps each specialist focused on its own task, avoids replaying the coordinator's large history (saving tokens), and lets isolated sub-agents run in parallel without interference.
Q3 · Sub-agent B needs a number that sub-agent A computed. How does B get it?
The coordinator collects A's result and passes it explicitly into B's delegated task. There is no shared memory between isolated sub-agents.