Skip to main content
Subagents are specialized agents that concentrate on sub-tasks delegated by a parent agent. Parallel subagents, each focused on a small part, achieve the overall goal faster. They are also more successful because the context that they provide to their language model contains much less noise. Each subagent has its own instructions, model, and tools. Subagents are ideal for:
  • Breaking complex tasks into specialized subtasks.
  • Parallel processing of independent work items.
  • Role-based delegation (researcher, writer, reviewer).
  • Isolating concerns with specialized tools and expertise.

Available Tools

When you configure subagents, the parent agent automatically gets these tools: See Subagent Tools for detailed parameter documentation.

Quick Start

Define subagents in your agent configuration:
images/main/main.py
images/main/Dockerfile
autonomy.yaml
The parent agent delegates tasks:
The manager agent will:
  1. Delegate research to the researcher subagent
  2. Delegate writing to the writer subagent
  3. Combine their responses

Configuring Subagents

Subagents are defined in the subagents parameter:

Configuration Options

Required:
  • instructions - System instructions defining the subagent’s role and behavior
Optional:
  • model - Model to use. Defaults to parent’s model if not specified
  • auto_start - Automatically start subagent on first delegation. Default: False
  • tools - List of tools available to the subagent
  • max_iterations - Maximum reasoning loops. Default: 10
  • max_execution_time - Timeout in seconds. Default: 60
  • max_messages_in_short_term_memory - Message limit. Default: 100
  • max_tokens_in_short_term_memory - Token limit. Default: 8000
  • enable_long_term_memory - Enable persistent memory. Default: False
  • runner_filter - Filter for distributing subagents across nodes

Subagent Tools

When you configure subagents, the parent agent automatically gets access to delegation tools:

start_subagent

Start a subagent manually:
Not usually needed - use auto_start: True instead.

delegate_to_subagent

Delegate a single task to a subagent:
Parameters:
  • role - The subagent role name (must match a key in subagents config)
  • task - Task description or prompt to send to the subagent

delegate_to_subagents_parallel

Delegate multiple tasks to parallel subagent instances:
Parameters:
  • role - The subagent role name
  • tasks - List of task descriptions
Creates one subagent instance per task and processes them concurrently.

list_subagents

List configured and running subagents:

stop_subagent

Stop a running subagent:
Rarely needed - subagents are automatically cleaned up when the parent stops.

Delegation Patterns

Sequential Delegation

Delegate tasks one at a time in sequence:

Parallel Delegation

Process multiple independent tasks concurrently:
Example usage:
The manager creates 3 researcher instances and processes all topics concurrently.

Role-Based Delegation

Different subagents for different expertise:

Auto-Start Behavior

Subagents start automatically on first use:
With auto_start: True:
  • Parent calls delegate_to_subagent(role="researcher", ...)
  • Framework automatically starts the subagent if not running
  • Task is delegated
  • No need to explicitly call start_subagent()
With auto_start: False (default):
  • Parent must explicitly call start_subagent(role="researcher") first
  • Then can call delegate_to_subagent(role="researcher", ...)
  • Useful when you want explicit control over lifecycle
Recommendation: Use auto_start: True for simpler agent logic.

Parallel Processing

Process multiple tasks concurrently with delegate_to_subagents_parallel:
Example:
Benefits:
  • Independent tasks complete dramatically faster
  • Scales to dozens of concurrent tasks
  • Automatic cleanup after completion

Runner Distribution

To distribute subagents across multiple runner nodes, use runner filters:
Runner filters:
  • Select which nodes run subagents
  • Distribute work across multiple machines
  • Format: "key1=value1,key2=value2"
  • Subagent-specific runner_filter overrides agent-level subagent_runner_filter
Configure runners in autonomy.yaml:

Subagent Memory

Subagents have their own isolated memory:
Memory behavior:
  • Each subagent instance maintains its own conversation history
  • Parent agent’s memory is separate from subagent memory
  • Subagents don’t see parent’s conversation history
  • Results return to parent as tool responses
For parallel subagents:
  • Each parallel instance has completely isolated memory
  • Instance A does not see Instance B’s history
  • Each task starts with a clean slate

Complete Example

Build a research and writing system with parallel processing:
images/main/main.py
autonomy.yaml
secrets.yaml
What happens:
  1. Coordinator breaks topic into 3 research questions
  2. Creates 3 researcher instances working in parallel
  3. Each researcher uses web search to find current information
  4. Coordinator synthesizes findings
  5. Delegates to writer for final article
  6. Returns polished, well-researched article

Best Practices

Choose Appropriate Models

Use different models for different subagent roles:

Set Appropriate Timeouts

Use auto_start for Simplicity

Provide Clear Instructions

Each subagent should have focused, clear instructions:

Handle Errors Gracefully

Provide error handling guidance in parent agent instructions: