Why Context Isolation Matters
The Finite Context Window
Every model has a finite context window — the working memory that holds your conversation. In a long Claude Code session, that window fills with tool outputs: file contents, search results, command logs, test output. None of it disappears on its own. As it accumulates, two problems appear: the model can lose track of earlier instructions, and each new turn costs more tokens to process the growing history.
Context is a budget, not infinite scroll
Treat the main context window like a budget you're spending. Every verbose tool result you let into it is money spent that you can't get back. Subagents let you do expensive, noisy work 'off the books' and bring back only the receipt.
Isolation Is the Mechanism
A subagent's context window starts fresh and is completely separate from the main conversation. The verbose middle — reading dozens of files, running greps, tracing call chains — happens entirely inside the subagent. Only the final message crosses back. This is what 'context isolation' means, and it's the single property that makes subagents valuable.
Left: every tool result piles into the one context. Right: the noise is quarantined in the subagent; the main context stays lean.
Three Things Isolation Buys You
| Benefit | What it means | Why it helps |
|---|---|---|
| Preserve context | Exploration/implementation stay out of the main thread | Longer sessions before degradation or compaction |
| Enforce constraints | A subagent can be limited to specific tools | A reviewer literally cannot edit files |
| Control costs | Route the task to a faster, cheaper model (e.g. Haiku) | Cheap bulk work without burning the main model |
Context isolation is not just tidiness — it unlocks constraint enforcement and cost control too.
That last point is easy to miss: because a subagent is a separate run, you can power it with a different, cheaper model. A high-volume search task can run on Haiku while your main conversation stays on a more capable model — you get speed and savings without sacrificing the main thread's quality.
Isolation Has Limits — Know Them
Isolation is powerful precisely because the subagent can't see your conversation. But that cuts both ways: the subagent does NOT inherit your conversation history, the files you've already read, or the skills you've invoked. The only channel from parent to subagent is the task prompt the parent writes.
Put what it needs in the task prompt
Because the subagent starts fresh, anything it needs — specific file paths, an error message, a decision already made — must be included in the delegation prompt. 'Review the auth changes' is weaker than 'Review src/auth/login.ts and src/auth/session.ts for security issues.' We'll use this fact heavily when designing effective subagents.
Next
Isolation is the engine. Before building custom subagents, let's meet the powerful built-in ones — Explore, Plan, and general-purpose — that Claude Code already uses for you.
Key Takeaways
- ✓The main context window is finite; in long sessions it fills with verbose tool output, causing the model to lose track and raising per-turn cost.
- ✓Context isolation means the subagent runs in a fresh, separate context; only its final message crosses back to the main thread.
- ✓Isolation buys three things: preserved context (longer sessions), enforced constraints (tool limits), and cost control (cheaper models like Haiku).
- ✓Because a subagent is a separate run, it can use a different/cheaper model than the main conversation.
- ✓The subagent does NOT inherit your conversation history, already-read files, or invoked skills — the only channel in is the task prompt.
- ✓Therefore: include everything the subagent needs (file paths, errors, decisions) directly in the delegation prompt.
Check Your Understanding
Test what you learned in this lesson.
Q1.What does 'context isolation' refer to in the context of subagents?
Q2.Besides keeping the main context clean, what else does isolation enable?
Q3.Which of these does a subagent NOT automatically inherit from the parent?
Q4.Given isolation's limits, how should you write a delegation prompt?
Practice This Lesson