Skip to main content

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
  • Isolated execution: Each subagent runs independently with its own state
  • 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
Key concepts:
  • UseSubagents: Capability that enables subagent spawning
  • AgentDefinitionRegistry: Registry of available subagent definitions
  • AgentDefinition: Defines subagent role, tools, and behavior
  • AgentEventConsoleObserver: Shows parent/child agent IDs for tracking orchestration

Example