Skip to main content

Subagents

Definition

Subagents are agents that sit within a hierarchy: a parent agent delegates sub-tasks to child agents (subagents), which may in turn delegate to further subagents. This structures complex work and keeps each agent focused.

They are one way to implement multi-agent systems with a clear chain of responsibility. The root agent owns the user-facing goal; subagents handle focused sub-tasks (e.g. retrieval, code execution, validation). Often used with spec-driven development or RDD so subagents receive and follow specs.

How it works

The root agent receives the task, breaks it into sub-tasks, and assigns them to Subagent1, Subagent2, etc. (by role or capability). Each subagent runs its own loop (possibly with tools and an LLM) and returns results to the root. The root aggregates results (e.g. merges, selects, or passes to another subagent) and either continues the loop or returns to the user. Subagents can be specialized (e.g. retrieval, code, critique) and use the same or different models. Clear contracts (inputs/outputs or tools) and error handling make the hierarchy debuggable and reusable.

Use cases

Subagents help when a task naturally splits into focused sub-tasks that can be delegated and aggregated.

  • Root agent delegating retrieval, generation, and validation to subagents
  • Complex workflows (e.g. research, code review) with focused sub-tasks
  • Reusing the same subagent in different parent workflows

External documentation

Pros and cons

ProsCons
Clear separation of concernsCoordination and latency
Scalable to complex tasksNeed clear contracts and error handling
Reusable subagent capabilitiesDebugging across hierarchy can be hard

See also