For agent-to-agent routing inside a conversation, prefer Handoffs. Use the subagent tool or delegator when you need programmatic spawn control, background jobs, or parallel fan-out.
Quick Start
How It Works
| Phase | What happens |
|---|---|
| 1. Delegate | The parent spawns a subagent with a scoped permission mode |
| 2. Execute | The subagent runs within its timeout and step limits |
| 3. Aggregate | Results flow back to the parent for a final answer |
Built-in Agent Profiles
| Agent | Mode | Description |
|---|---|---|
general | Primary | General-purpose coding assistant |
coder | All | Focused code implementation |
planner | Subagent | Task planning and decomposition |
reviewer | Subagent | Code review and quality |
explorer | Subagent | Read-only codebase investigation |
debugger | Subagent | Debugging and troubleshooting |
Parallel Delegation
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
max_concurrent_subagents | int | 3 | Max subagents running at once |
max_total_subagents | int | 10 | Max total spawned |
default_timeout_seconds | float | 300.0 | Default task timeout |
max_timeout_seconds | float | 600.0 | Maximum allowed timeout |
max_steps_per_subagent | int | 50 | Max steps per subagent |
max_tokens_per_subagent | int | 50000 | Max tokens per subagent |
inherit_permissions | bool | True | Inherit from parent |
allow_nested_delegation | bool | False | Allow subagents to delegate |
auto_cancel_on_parent_cancel | bool | True | Cancel children when parent stops |
collect_results | bool | True | Aggregate results |
Model and Permission Modes
| Mode | Description |
|---|---|
default | Standard permission checking |
accept_edits | Auto-accept file edits |
dont_ask | Auto-deny prompts |
bypass_permissions | Skip all checks (dangerous) |
plan | Read-only exploration mode |
create_subagent_tool parameters and background mode.
Task Management
Convenience Function
Best Practices
Match agent profiles to the task
Match agent profiles to the task
Use
explorer for read-only scans, coder for implementation, and reviewer for quality checks.Set timeouts on long tasks
Set timeouts on long tasks
Prevent runaway subagents with
default_timeout_seconds or per-call overrides.Limit concurrency
Limit concurrency
Keep
max_concurrent_subagents low to avoid overwhelming APIs or local resources.Prefer plan mode for exploration
Prefer plan mode for exploration
Use
permission_mode="plan" when subagents should not modify files.Related
Subagent Tool
Spawn subagents from a parent agent’s tool list
Spawn & Announce
Non-blocking parallel sub-agent orchestration
Agent Profiles
Built-in profile definitions
Handoffs
Conversation-based agent routing

