wiki / concepts / subagents-and-context-management

Subagents and Context Management

high confidence updated 2026-08-30 agents · subagents · context-engineering · workflow

Subagents and Context Management

LLM context windows carry token budgets and degrade in reasoning sharpness as conversations grow bloated. Subagents solve this by isolating high-token exploratory work in ephemeral child contexts, returning only concise summaries to the root agent.

dispatch  -> subagent context = goal + minimal files + output schema
collect   -> parent receives result summary only (not the transcript)

Core Roles

  • Exploration (e.g. Claude Code Explore): An isolated subagent searches the tree, locates relevant views/templates/functions, and hands back exact file paths and line numbers without flooding the root session.
  • Parallel Subagents: Independent tasks (e.g. updating 5 decoupled template files or refactoring independent modules) dispatched concurrently across child agents to accelerate throughput.
  • Specialist Subagents: Delegating specific roles like code reviewer, verbose test-runner filter, or debugger to dedicated prompts with customized system instructions.

Context Preservation Rule

The primary value of subagents is not unnecessary complexity, but preserving the root agent’s context window for architectural decisions, high-level verification, and user steering.

Failure Modes

SymptomRoot causeFix
Subagent returns useless summaryGoal under-specified at dispatchGoal = task + files + output schema, written down before dispatch
Parent context explodes on collectFull transcripts merged backCollect result summaries only; transcripts stay in the subagent
Subagents duplicate workOverlapping scopesPartition by file/area ownership before dispatch
Lost consensus across agentsNo synthesis stepOne parent-side synthesis pass over all summaries

Rule of Thumb

Rule of Thumb

A subagent gets a goal, the minimum files, and an output schema - never the parent transcript. If it needs the transcript, the task split is wrong.