Quick Start
Configuration Options
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_factory | Callable | None | Custom function to create agents |
allowed_agents | List[str] | None | Restrict which agent types can be spawned |
max_depth | int | 3 | Maximum subagent nesting depth |
default_llm | str | None | Default LLM model for subagents |
default_permission_mode | str | None | Default permission mode |
Spawn Parameters
When calling the subagent function:| Parameter | Type | Required | Description |
|---|---|---|---|
task | str | ✅ Yes | Task description for the subagent |
agent_name | str | No | Specific agent type to use |
context | str | No | Additional context for the task |
tools | List[str] | No | Tools to give the subagent |
llm | str | No | LLM model override |
permission_mode | str | No | Permission mode override |
Model Selection
Model selection priority:- Per-call
llmparameter - Highest priority default_llmfrom tool creation - Fallback- Agent’s default model - Final fallback
Permission Modes
| Mode | Value | Description |
|---|---|---|
default | Standard | Normal permission checking |
accept_edits | Auto-accept | Auto-accept file edits |
dont_ask | Auto-deny | Auto-deny all prompts |
bypass_permissions | Bypass | Skip all checks |
plan | Read-only | Exploration mode only |
Custom Agent Factory
Create agents with custom configurations:Depth Limiting
Prevent infinite subagent recursion:Agent Restrictions
Limit which agent types can be spawned:Result Structure
Best Practices
Use appropriate models
Use appropriate models
Use smaller models like
gpt-4o-mini for simple tasks and larger models for complex analysis.Set permission modes
Set permission modes
Always set
permission_mode="plan" for exploration tasks to prevent accidental modifications.Limit allowed agents
Limit allowed agents
Restrict
allowed_agents to only the agent types needed for your use case.Handle errors
Handle errors
Always check
result["success"] before accessing the output.Related
Subagent Delegation
Advanced subagent management
Permission Modes
Permission mode details

