Overview
Subagents enable decomposition of complex tasks into isolated subtasks. The main agent orchestrates multiple subagents, each with specialized roles and tools. This pattern provides:- Context isolation: Each subagent has clean context without cross-contamination
- Parallel execution: Multiple subagents can work simultaneously
- Specialized capabilities: Each subagent has specific tools for its role
- Scalability: Handle many independent subtasks without context overflow
- Result aggregation: Main agent synthesizes subagent outputs
UseSubagents: Capability that enables subagent spawningAgentRegistry: Registry of available subagent specificationsAgentSpec: Defines subagent role, tools, and behaviorspawn_subagent: Tool to create and execute subagent- Context isolation: Subagents don’t see each other’s work
Example
Expected Output
Key Points
- Context isolation: Each subagent reviews independently without seeing other reviews
- Scalability: Main agent context stays clean even with many subagent calls
- Specialized roles: Each subagent has specific tools and instructions
- Result aggregation: Main agent synthesizes all subagent outputs
- Parallel potential: Subagents can execute concurrently (implementation-dependent)
- AgentRegistry: Central registry of available subagent types
- Policy control: SubagentPolicy defines spawning limits and behavior
- Clean architecture: Separation between orchestration and execution
- Use cases: Code review batches, multi-document analysis, parallel research, task decomposition
- Metadata tracking: Track subagent spawns and execution statistics