Skip to main content

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 the spawn 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

In HEARTBEAT.md, spawn subagents for tasks that take time:
The main agent spawns a subagent for each long task, then continues to the next heartbeat task. The subagent uses the message tool to deliver results directly to the user.
Execute multiple independent tasks simultaneously:
Both subagents run concurrently and deliver results via the message tool.
Route tasks to specialized agents:

Subagent Communication

Subagents communicate with users through the message 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:
If 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_workspace setting
  • Exec safety - Same dangerous pattern blocks
  • Path restrictions - Same allow/deny path patterns
  • Tool access - Same tool availability
There is no way to bypass security through subagents.

Example: Heartbeat with Spawn

HEARTBEAT.md:
Agent behavior:
  1. Agent reads HEARTBEAT.md
  2. Spawns first subagent with search task
  3. Spawns second subagent with calendar task
  4. Returns HEARTBEAT_OK immediately
  5. Subagents execute independently and message user with results

Troubleshooting

  • Check if target agent is in allowlist
  • Verify agent ID exists in configuration
  • Check logs for spawn errors
  • Ensure subagent uses message tool to deliver results
  • Check if subagent completed successfully (logs)
  • Verify channel context is available
  • 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