SubAgent
Core Facts
Claude Code supports breaking large tasks into multiple subtasks for parallel processing through a SubAgent (sub-agent) architecture.
The Subagent architecture decomposes complex tasks and distributes them to specialized sub-agents for parallel processing, with each sub-agent's context window containing only information relevant to its responsibilities.
Timeline (last 90 days)
The context isolation of SubAgent brings two benefits: it prevents intermediate processes from polluting the main conversation, and subtasks can run in parallel without blocking; the cost is that the task description must be self-contained.
The key difference between SubAgent and ordinary conversation lies in context isolation: a sub-agent has an independent, clean context window, receives only the task description sent down by the main agent, and returns conclusions.
Subagents are used for code review and task decomposition.
Each SubAgent must carry its own system prompt and task description, and the aggregation of results between the master and the slaves also consumes tokens and one round of inference.
Super Agent takes roughly only half the time of the single-session scheme with SubAgent tools.
Only by using MCP, Skills, SubAgent, and Hooks together with permission modes can Claude Code's capability as an orchestratable system be brought into play.
Implement Spec orchestrates Tickets using a SubAgent loop, on the grounds that having a single Coding Agent complete an entire Spec in one go easily puts it into an error-making state and triggers automatic compaction.
SubAgents can now further spawn SubAgents, so orchestration becomes a tree structure, which is the technical prerequisite for Implement Spec to automatically execute the Ticket graph.
The essence of a SubAgent is context partitioning — creating an independent context window for each subtask to ensure that the subtask context does not contaminate the main task, fundamentally cutting off the token accumulation effect.
All Facts (20)
Claude Code supports breaking large tasks into multiple subtasks for parallel processing through a SubAgent (sub-agent) architecture.
80%VerifiedThe Subagent architecture decomposes complex tasks and distributes them to specialized sub-agents for parallel processing, with each sub-agent's context window containing only information relevant to its responsibilities.
70%UnverifiedThe current SubAgent implementation can only execute sub-agents serially and does not support parallel execution.
95%UnverifiedIn the run_subagent function, sub-agent execution is limited to 30 loop iterations.
95%UnverifiedIn the SubAgent architecture, the parent agent's toolset includes one additional task tool on top of the sub-agent's tools, used for dispatching tasks.
95%UnverifiedThe core purpose of the SubAgent (sub-agent) solution is to achieve context isolation, preventing conversations from being polluted by intermediate information generated by tool calls.
95%UnverifiedAfter the sub-agent completes its task, the text blocks from the final round are extracted and concatenated into a summary using the join method, which is then returned to the parent agent as a tool result.
90%UnverifiedSub-agent lifecycles are very short, existing only during task execution and being destroyed after the task is complete; whereas each agent in Agent Teams is long-lived and persistent.
90%Unverified将SubAgent改造为并行执行需要解决任务依赖图构建、结果聚合和资源竞争(如文件读写加锁)三个技术挑战
85%UnverifiedThe System Prompt design for parent and child agents in the SubAgent architecture reflects the single responsibility principle in software engineering.
80%UnverifiedThe context isolation of SubAgent brings two benefits: it prevents intermediate processes from polluting the main conversation, and subtasks can run in parallel without blocking; the cost is that the task description must be self-contained.
50%UnverifiedThe key difference between SubAgent and ordinary conversation lies in context isolation: a sub-agent has an independent, clean context window, receives only the task description sent down by the main agent, and returns conclusions.
50%UnverifiedSubagents are used for code review and task decomposition.
50%UnverifiedEach SubAgent must carry its own system prompt and task description, and the aggregation of results between the master and the slaves also consumes tokens and one round of inference.
50%UnverifiedOnly by using MCP, Skills, SubAgent, and Hooks together with permission modes can Claude Code's capability as an orchestratable system be brought into play.
50%UnverifiedImplement Spec orchestrates Tickets using a SubAgent loop, on the grounds that having a single Coding Agent complete an entire Spec in one go easily puts it into an error-making state and triggers automatic compaction.
50%UnverifiedSubAgents can now further spawn SubAgents, so orchestration becomes a tree structure, which is the technical prerequisite for Implement Spec to automatically execute the Ticket graph.
50%UnverifiedThe essence of a SubAgent is context partitioning — creating an independent context window for each subtask to ensure that the subtask context does not contaminate the main task, fundamentally cutting off the token accumulation effect.
50%UnverifiedIn mainstream frameworks such as OpenAI's Agents SDK and LangGraph, SubAgents are typically modeled as tools or nodes that can be called by a parent Agent, with data passed directly through function calls, message queues, or shared memory.
50%UnverifiedSubAgent 模式在 AutoGPT、CrewAI、MetaGPT 等多 Agent 框架中被广泛采用
50%