Overview
PicoClaw supports spawning subagents - independent agent instances that can execute tasks asynchronously without blocking the main agent. This is particularly useful for:- Long-running tasks (web searches, API calls)
- Parallel task execution
- Background jobs triggered by heartbeat
- Tasks that need isolation from the main conversation context
How Subagents Work
When you use thespawn tool, PicoClaw creates a new agent instance with:
- Independent context - No access to the parent’s conversation history
- Same workspace - Inherits workspace path and restrictions
- Tool access - Has access to all tools (message, web_search, exec, etc.)
- Isolated execution - Runs asynchronously without blocking the parent
Subagents inherit the same security restrictions as the parent agent (workspace sandboxing, exec safety patterns, etc.)
Using the Spawn Tool
Basic Syntax
With Target Agent
Common Use Cases
Heartbeat Long-Running Tasks
Heartbeat Long-Running Tasks
In The main agent spawns a subagent for each long task, then continues to the next heartbeat task. The subagent uses the
HEARTBEAT.md, spawn subagents for tasks that take time:message tool to deliver results directly to the user.Parallel Processing
Parallel Processing
Execute multiple independent tasks simultaneously:Both subagents run concurrently and deliver results via the
message tool.Specialized Agent Routing
Specialized Agent Routing
Route tasks to specialized agents:
Subagent Communication
Subagents communicate with users through themessage tool:
Subagents don’t return data to the parent agent. They deliver results directly to the user via the
message tool or take actions using other tools.Configuration
Allow List
Subagents can be restricted by configuration:allowlist is set, only agents in the list can be spawned.
Agent-Specific Subagent Config
Best Practices
Use for I/O-bound tasks
Web searches, API calls, file operations - anything that waits for external resources
Keep prompts focused
Give subagents clear, specific tasks with all necessary context in the prompt
Don't overuse
Each subagent uses memory and resources. Use judiciously for truly parallel work
Handle errors gracefully
Subagents may fail independently. Ensure main flow continues
Security
Subagents inherit all security restrictions:- Workspace sandbox - Same
restrict_to_workspacesetting - Exec safety - Same dangerous pattern blocks
- Path restrictions - Same allow/deny path patterns
- Tool access - Same tool availability
Example: Heartbeat with Spawn
HEARTBEAT.md:- Agent reads HEARTBEAT.md
- Spawns first subagent with search task
- Spawns second subagent with calendar task
- Returns HEARTBEAT_OK immediately
- Subagents execute independently and message user with results
Troubleshooting
Subagent not spawning
Subagent not spawning
- Check if target agent is in allowlist
- Verify agent ID exists in configuration
- Check logs for spawn errors
No response from subagent
No response from subagent
- Ensure subagent uses
messagetool to deliver results - Check if subagent completed successfully (logs)
- Verify channel context is available
Memory usage increasing
Memory usage increasing
- Each subagent uses resources
- Limit concurrent subagents
- Use spawn only when necessary
Next Steps
Spawn Tool API
Complete API reference for the spawn tool
Heartbeat Feature
Learn about periodic tasks and HEARTBEAT.md
Message Tool
How subagents communicate with users
Agent Configuration
Configure agents and subagent allowlists