Claude Sub-Agents and Context Isolation, Explained
Claude sub-agents context isolation explained: why each sub-agent starts empty, hub-and-spoke handoffs, parallel spawning, and when to fork vs start fresh.
Updated
Claude sub-agents run in isolated context: each one is a fresh session that inherits none of the coordinator’s conversation history, tool results, or earlier findings, and knows only what the coordinator writes into its task prompt. That isolation is deliberate. It keeps verbose exploration out of the main context, lets each specialist work with a small, role-specific tool set, and forces the coordinator to hand off facts explicitly, which is what makes results aggregatable and auditable.
It is also the single most common source of multi-agent bugs, and Domain 1 of the Claude Certified Architect – Foundations exam (Agentic Architecture & Orchestration, 27%) returns to it repeatedly.
Why do sub-agents start with an empty context?
Three reasons, all of which show up as exam rationales.
Context budget. Reading 45 files in the main session can consume three-quarters of the context window and degrade every later step; the same discovery delegated to an isolated Explore sub-agent came back as a 12%-of-context summary while covering 120 files. The main session keeps its budget for implementation. See Explore sub-agent context isolation and, from Domain 5, sub-agent delegation isolation.
Tool selection accuracy and least privilege. Sub-agents do not inherit the coordinator’s tools either. Each AgentDefinition lists its own tools; omit the field and the sub-agent inherits everything, including Bash and Write it should not have. A code-review agent with [Read, Grep, Glob] structurally cannot modify files, and an agent choosing among 3–5 tools selects far more reliably than one facing 18. See Task tool and allowedTools and the Foundations article on sub-agents in the Agent SDK.
Explicit handoff. Because nothing is shared implicitly, the coordinator must decide what each specialist needs. That constraint is what makes outputs comparable and provenance traceable. It also removes the temptation to add Redis or a shared database; prompt-based context passing already solves the problem with no race conditions.
The misconception the exam probes is “the sub-agent will see what the coordinator already found.” It will not. The classic symptom is duplicated work: the coordinator has already located five key papers, sends “analyze the research findings,” and the sub-agent goes searching again. See sub-agents see nothing.
How does hub-and-spoke orchestration use isolation?
In hub-and-spoke, every message flows through the coordinator. Sub-agents never call each other. The coordinator decomposes the request, delegates only to the specialists a given request needs (roughly 70% of support tickets need one), aggregates results, resolves conflicts, handles partial failure, and synthesizes. A mesh, where agents call agents, distributes those responsibilities across components never designed for them: when one stage fails, nobody owns the retry.
The coordinator prompt should set goals and quality standards, not a rigid step list. Goal-oriented coordinator prompts scored 82 versus 68 for procedural ones in the study data, mainly because 45% of queries benefit from a strategy change mid-task (“the search found two papers and one government report” should not be discarded because step 1 said “papers”). Separate adaptive strategy from fixed output format so auditors still get a predictable report. See hub-and-spoke and coordinator prompt design.
Mechanically, delegation is the Task tool with three required inputs (description, a 3–5 word log label; prompt, the full task with context; subagent_type, the key of an AgentDefinition) and four response fields (result, usage, total_cost_usd, duration_ms). The coordinator must have Task in its own allowed tools or delegation fails outright, and it must be told to use the result field, or it may answer from its own uninformed guess. See Task tool invocation.
What should a structured handoff contain?
Curated, structured, task-specific context. Not the whole history: one production system was sending 25,000 tokens to each of three sub-agents when the search agent needed about 500 (query plus scope), the analysis agent about 3,000 (papers plus criteria), and the synthesis agent about 8,000 (all findings). Quality tracks completeness in the other direction too: a billing sub-agent given full customer and order context scored 92%, an account sub-agent given only a name scored 65%.
Include two things teams routinely forget: the domain rules the sub-agent must apply (security policy, coding standards) and the output format the coordinator will aggregate. Structured JSON preserves attribution; prose destroys it. A finding passed as “several studies show rapid growth” cannot be verified; passed as a claim-source object with URL, date, and excerpt, it can. Downstream agents that received narrative summaries produced 35% wrong file paths in one case; switching to {"file": ..., "line": ..., "issue": ...} fixed it. When two sources conflict, preserve both with attribution rather than averaging into a number neither reported. See context passing best practices, and for the human-escalation variant of the same idea, structured handoff protocol.
When should sub-agents run in parallel?
Whenever they are independent. If the coordinator emits several Task calls in one response, they execute concurrently; total time becomes the longest agent, not the sum. Three 30-second agents take 30 seconds instead of 90, at identical token cost.
Parallelize within independence, sequence across dependencies. OCR then NLP then validation cannot run side by side, but document A and document B can. Mixed graphs are handled in phases: run everything unblocked, collect, run what just became unblocked. When one parallel branch fails, keep the successful results, record the failure with structured context, and either retry that branch alone or proceed with an explicit gap annotation, never silently. See parallel sub-agent spawning.
Resume, fork, or fresh session?
Isolation is the default, but you have three ways to relate a follow-up to prior work.
| Need | Mechanism | Why |
|---|---|---|
| Linear follow-up on the same task (“now suggest fixes”) | Resume the sub-agent’s session_id | Keeps accumulated context; about 85% fewer prompt tokens than re-injecting |
| Compare alternatives from a shared baseline | Fork the session per alternative | Prevents anchoring bias: forked evaluation reached 89% expert agreement vs 62% sequential |
| Unrelated new task | Fresh session | Prior context is only noise and budget |
Fork’s cost (about 1.8x) is justified only for genuinely divergent exploration; one team forked twelve times per task when three were divergent and nine were clarifications that should have been resumes. Do not share findings between forks, and synthesize with a coordinator that took part in none of the branches. Cache every session_id you get back; they are cheap strings and you cannot resume without one. In Claude Code, context: fork on a Skill isolates the conversation but not the filesystem: files the fork writes persist, its verbose reasoning does not. See sub-agent resume, fork-based sessions, and fork isolates memory, not the filesystem.
A worked example
A support coordinator receives: “I was double-charged for order 8812 and I want the duplicate refunded to my card.” Its own context already holds the verified customer ID, both charge records, and the policy that refunds above $500 need approval.
A weak coordinator delegates “look into this customer’s refund” to a billing sub-agent. The sub-agent, starting empty, re-looks up the customer, may miss the second charge, and returns prose. Quality drops and tokens double.
A sound coordinator sends the billing sub-agent a task prompt containing: customer ID (already verified, do not re-verify), the two charge records with IDs and amounts, the refund policy tiers, the customer’s stated expectation (refund to card, not store credit), and a required output schema ({duplicate_charge_id, refund_amount, needs_approval, customer_message}). It runs a shipping-status check in parallel only if the request needs one; here it does not. If the refund exceeds $500, a PreToolUse hook on process_refund denies with a redirect to escalation regardless of what either agent reasons. When the sub-agent returns, the coordinator reads result, keeps the session_id in case the customer follows up, and drafts the reply.
Every improvement in the second version comes from taking isolation seriously: pass what is known, restrict what can be done, structure what comes back.
Next step
Read Tasks 1.2 and 1.3 of the Domain 1 study guide in order, then attempt the Domain 1 practice set and watch for scenarios where the wrong answer assumes shared state. The free 60-question mock exam weights Domain 1 at the official 27%, so orchestration questions will be a large share of it. Confirm current exam details such as the US$125 fee and 120-minute format on the official Anthropic / Pearson VUE page before you register.
Frequently asked questions
Does a sub-agent see the coordinator's CLAUDE.md or system prompt?
expand_more
It sees its own AgentDefinition system prompt and tools, not the coordinator's conversation. Any project rule or standard the sub-agent must follow has to be included in its own prompt or passed in the task prompt.
Is a forked session the same as a sub-agent?
expand_more
No. A sub-agent starts empty and receives only what the coordinator passes. A fork copies the full context up to the fork point and then diverges, which is what you want for comparing alternatives without anchoring bias.
How much context should the coordinator pass to each sub-agent?
expand_more
Only what that task needs, in structured form. One system that sent its full 25,000-token history to each of three sub-agents cut total tokens by about 85% after curating per-task context, with no quality loss.
Put it into practice
Take the free 60-question Claude Certified Architect mock exam, or work through the CCA-F study guide domain by domain.
Certified Architect is an independent, community-built study site. Exam facts reflect public Anthropic / Pearson VUE information and can change — always confirm on the official pages before registering.