What you will be able to do
- Delegate verbose exploration to subagents while the main agent keeps the high-level picture, and recognise when delegation is overkill
- Summarise one exploration phase and inject that summary into the prompts of the next phase's subagents
- Design crash recovery around per-agent state files and a manifest the coordinator loads on resume
1.Delegating exploration to subagents
Compaction and scratchpads help a single agent manage its own context. Subagents go further: the verbose exploration never enters the main context in the first place. Each subagent runs in its own conversation. Its intermediate tool calls and results stay inside it, and only its final message goes back to the parent. A subagent might use tens of thousands of tokens exploring and return a distilled summary of perhaps 1,000–2,000 tokens. This splits the work cleanly. The main agent works from a high-level plan, and subagents do the deep searching.
This works best when each subagent gets one specific question, such as "find all test files" or "trace refund flow dependencies". The best-practices guide gives an example prompt in the same style: *"Use subagents to investigate how our authentication system handles token refresh, and whether we have any existing OAuth utilities I should reuse."* Several such subagents can run at once, so independent questions finish in the time of the slowest one. Claude Code includes built-in subagent types for this kind of work:
| Subagent | Tools | Purpose |
|---|---|---|
| Explore | Read-only tools; Write and Edit are denied | File discovery, code search, codebase exploration |
| Plan | Read-only tools; Write and Edit are denied | Codebase research for planning |
| General-purpose | Every tool available to subagents | Complex research, multi-step operations, code modifications |
Checkpoint 1 of 7· Check yourself
An Explore subagent reads 60 files to trace a dependency chain. What ends up in the main agent's context?
Context isolation is the reason to delegate. The file reads stay in the subagent's window, and only its final message reaches the parent.
“intermediate tool calls and results stay inside the subagent; only its final message returns to the parent.”Source: code.claude.com
Delegation has a cost. Anthropic's data shows that agents use about 4× more tokens than chat interactions, and multi-agent systems about 15× more. Most coding tasks also have fewer truly parallel parts than research does. The fix for the infinite-exploration anti-pattern is "scope investigations narrowly *or* use subagents", and the order of those options matters. For a narrow lookup, such as finding one function in a small module, a scoped search in the main session is cheaper than briefing and coordinating a subagent. Save delegation for exploration that would otherwise flood your context.
Checkpoint 2 of 7· Exam question
An architect needs to understand how a refund flow touches the payments, ledger, and notification services before proposing a redesign. The main agent should stay focused on synthesizing the redesign proposal rather than tracing every function call itself. How should the architect structure this investigation?
Correct answer: C — Delegate a subagent with the bounded question of tracing refund flow dependencies across the three services and report a distilled summary.
- A. Incorrect. Reading every file's full contents into the main agent's context reintroduces the exact problem delegation is meant to solve, consuming space needed for the redesign work.
- B. Incorrect. Guessing based on other codebases risks the same generic, unverified answers that context degradation produces; the flow must be traced in this specific codebase.
- C. Correct. A bounded, specific delegation lets the subagent do the verbose tracing work in its own context and return only a distilled summary, keeping the main agent free to coordinate the redesign.
- D. Incorrect. An unscoped subagent without a specific question tends to explore broadly and return diffuse output, undermining the benefit of isolating a focused investigation.
Checkpoint 3 of 7· Check yourself
You need to find the one function in a small, familiar module that formats invoice dates, and then make a single edit. What is the proportionate approach?
Subagents pay off when exploration would otherwise flood the main context. For a small, well-scoped lookup, a narrow search avoids the overhead of multi-agent work.
“Scope investigations narrowly or use subagents so the exploration doesn’t consume your main context.”Source: code.claude.com
2.Carrying findings between exploration phases
Context isolation means subagents start clean, so they also start uninformed. Claude Code shows the difference between the two kinds of subagent:
| Aspect | Fork | Non-fork subagent |
|---|---|---|
| Context | Full conversation history | Fresh context with the prompt you pass |
| System prompt and tools | Same as main session | From the subagent's definition file |
| Prompt cache | Shared with main session | Separate cache |
A fork inherits everything, including the verbose phase-1 output you wanted to keep out of new contexts. A non-fork subagent inherits nothing. The pattern that avoids both problems is to summarise first and then inject the summary. Anthropic's research system works this way: agents summarise completed work phases and store the essential information in external memory before moving on. When context limits approach, they spawn fresh subagents and keep continuity through careful handoffs.
Applied to codebase exploration: when phase 1 ends, the coordinator condenses its findings. That means the confirmed classes, entry points and open questions, not raw file dumps. The coordinator writes this summary to its scratchpad and places it at the start of each phase-2 subagent's prompt. Each new subagent then begins with the established facts and spends its budget on the new question. It does not rediscover phase 1 or fall back on guesses about typical structure.
Checkpoint 4 of 7· Check yourself
Before spawning phase-2 subagents, what should the coordinator do with phase-1 results?
Summarising before the handoff keeps each subagent's starting context small and informative. Raw results would bloat it, and no briefing would leave the subagent without context.
“We implemented patterns where agents summarize completed work phases and store essential information in external memory before proceeding to new tasks.”Source: www.anthropic.com
3.Crash recovery with exported state and a manifest
Long multi-agent explorations run for hours, and in agent systems errors compound. Anthropic's research team decided that restarting from scratch was too expensive. Instead, they built systems that can resume from where the agent was when the error occurred. Three documented practices show how to build that.
1. Every agent writes its state to a known place. In Anthropic's research system, subagents call tools to store their work in external systems and pass only lightweight references back to the coordinator. The aim is artifacts that persist independently. Give each subagent its own output file, never a shared one. Concurrent subagents then cannot overwrite each other's findings, and a crash in one leaves the others' results intact. Claude Code applies the same idea to its own subagents: their transcripts are stored in separate files, are unaffected when the main conversation compacts, and can be resumed after a restart by resuming the same session.
2. Use a structured format for state. Anthropic's long-running-agent harness tracked progress with a claude-progress.txt file and git history. It also kept a feature list in JSON, because the model is less likely to inappropriately change or overwrite JSON than Markdown:
{
"category": "functional",
"description": "New chat button creates a fresh conversation",
"steps": [
"Navigate to main interface",
"Click the 'New Chat' button",
"Verify a new conversation is created",
"Check that chat area shows welcome state",
"Verify conversation appears in sidebar"
],
"passes": false
}Checkpoint 5 of 7· Exam question
A main agent is coordinating exploration of a repository with over 50,000 files and needs a complete list of every test file before planning a coverage audit. Running the search directly would flood the main conversation with thousands of matched paths it will not need again. What best keeps the main agent's context focused on high-level coordination while still producing the list?
Correct answer: B — Spawn a subagent to search for test files and return only the consolidated list, leaving the raw output isolated in its own context.
- A. Incorrect. Keeping the full raw search output in the main conversation is exactly the pattern that floods the coordinating agent's context with data it will not use again.
- B. Correct. Delegating the search isolates the verbose discovery output in the subagent's own context window; the main agent receives only the distilled list and keeps its context free for coordination.
- C. Incorrect. Manually collecting the list defeats the purpose of using the agent for exploration and adds unnecessary user burden for a task the agent can perform directly.
- D. Incorrect. Reading every file's contents sequentially in the main agent is far more expensive than a targeted search and consumes even more context than the raw search output would.
Checkpoint 6 of 7· Check yourself
Four subagents explore different modules at the same time and record findings as they go. Which convention best ensures the coordinator can reliably aggregate every result?
Separate, independently persisted artifacts can't overwrite each other, and references keep the coordinator's context small.
“implement artifact systems where specialized agents can create outputs that persist independently.”Source: www.anthropic.com
3. Start every resumed session by reading the state back in. In Anthropic's harness, each fresh session first gets its bearings: it runs pwd, reads the git log and progress file, then reads the feature list and picks the highest-priority unfinished item. The exam calls the coordinator-level version of this a manifest: an index of which agents ran, where each one's state file lives and what is still open. The documentation does not define a manifest format. It is a pattern assembled from the practices above. On resume, the coordinator loads the manifest, reads the referenced state files and injects the relevant findings into each restarted subagent's prompt. Non-fork subagents only know what their prompt tells them, so they cannot recover state any other way.
Checkpoint 7 of 7· Put it in order
Put the harness's get-your-bearings steps for a fresh session in order
- 1.Read the features list and choose the highest-priority feature not yet done
- 2.Run pwd to see the working directory
- 3.Read the git logs and progress files to see what was recently worked on
The agent first confirms where it is, then reconstructs recent history from persisted state, and only then chooses its next unit of work.
“Read the git logs and progress files to get up to speed on what was recently worked on.”Source: www.anthropic.com
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.Every search should go to a subagent, because delegation always saves context.Why is that wrong?
Multi-agent work costs far more tokens than a single conversation. A narrow lookup is cheaper as a scoped search in the main session.
Covered in Delegating exploration to subagents
2.A newly spawned subagent already knows what earlier phases discovered, because it shares the coordinator's session.Why is that wrong?
A non-fork subagent starts with a fresh context that contains only the prompt you pass. Earlier findings must be summarised and injected into that prompt.
Covered in Carrying findings between exploration phases
3.Compacting the main conversation also compacts, and loses detail from, subagent transcripts.Why is that wrong?
Subagent transcripts are stored in separate files and are not affected by main-conversation compaction.
Covered in Crash recovery with exported state and a manifest
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://code.claude.com/docs/en/context-windowOfficial docs
“Delegate large reads: send research to a subagent so the file contents stay in its context window, not yours.”
↩︎ Delegating exploration to subagents - 2.
“The main agent coordinates with a high-level plan while subagents perform deep technical work or use tools to find relevant information.”
↩︎ Delegating exploration to subagents“returns only a condensed, distilled summary of its work (often 1,000-2,000 tokens)”
↩︎ Delegating exploration to subagents - 3.
“multi-agent systems use about 15× more tokens than chats”
↩︎ Delegating exploration to subagents“We implemented patterns where agents summarize completed work phases and store essential information in external memory before proceeding to new tasks.”
↩︎ Carrying findings between exploration phases“Instead, we built systems that can resume from where the agent was when the errors occurred.”
↩︎ Crash recovery with exported state and a manifest“Subagents call tools to store their work in external systems, then pass lightweight references back to the coordinator.”
↩︎ Crash recovery with exported state and a manifest“multi-agent systems use about 15× more tokens than chats”
↩︎ Exam trap 1“implement artifact systems where specialized agents can create outputs that persist independently.”
↩︎ Checkpoint - 4.https://code.claude.com/docs/en/sub-agentsOfficial docs
“Fresh context with the prompt you pass”
↩︎ Carrying findings between exploration phases“You can resume a subagent after restarting Claude Code by resuming the same session.”
↩︎ Crash recovery with exported state and a manifest“Fresh context with the prompt you pass”
↩︎ Exam trap 2“when the main conversation compacts, subagent transcripts are unaffected.”
↩︎ Exam trap 3 - 5.
“the model is less likely to inappropriately change or overwrite JSON files compared to Markdown files.”
↩︎ Crash recovery with exported state and a manifest“Read the git logs and progress files to get up to speed on what was recently worked on.”
↩︎ Checkpoint
Also cited
- https://code.claude.com/docs/en/agent-sdk/subagentsOfficial docs
“intermediate tool calls and results stay inside the subagent; only its final message returns to the parent.”
↩︎ Checkpoint - https://code.claude.com/docs/en/best-practicesOfficial docs
“Scope investigations narrowly or use subagents so the exploration doesn’t consume your main context.”
↩︎ Checkpoint