Overview
Spawn tools enable agents to create background subagents that run independently with their own message history. Subagents share the same LLM provider and tool registry but have isolated context. Results are reported back via the message tool.Tools
spawn
Spawn a background subagent for a task. Use for long-running or parallel work.Description of the task for the subagent to perform
Additional context or instructions for the subagent
check_subagent
Check the status and result of a previously spawned subagent by its ID.ID of the subagent to check
running— Subagent is actively workingcompleted— Task finished successfullyfailed— Task failed with an errorcancelled— Task was cancelled manually
list_subagents
List all spawned subagents with their IDs, statuses, and task descriptions. Example:Lifecycle Management
Subagent Creation
Whenspawn() is called:
- A unique ID is generated (
sub_[8-char-hex]) - The task is wrapped in an asyncio task with error handling
- The subagent executes using the spawn callback provided in
ToolContext - The task runs in the background while the main agent continues
Result Reporting
Subagents should usesend_message to report results:
Cleanup
Completed/failed/cancelled subagents are automatically pruned when the count exceeds 50 to prevent unbounded memory growth. The oldest finished tasks are evicted first.Use Cases
Parallel Processing
Long-Running Tasks
Background Monitoring
Error Handling
Spawn Unavailable
Subagent Failure
Invalid Agent ID
Best Practices
- Use spawn for tasks that take longer than 30 seconds to avoid blocking the main agent
- Provide clear task descriptions — they’re visible to the LLM during execution
- Add context for complex tasks to give the subagent necessary information
- Have subagents send_message with results instead of relying on check_subagent polling
- List subagents periodically to track overall progress when running many parallel tasks
- Don’t spawn subagents for simple tasks — adds overhead
Limitations
- No direct communication between subagents (use send_message to user and have main agent coordinate)
- No cancellation API in current version (subagents run until completion or failure)
- No resource limits per subagent (can consume unlimited workspace resources)
- No priority system (all subagents run with equal priority)
- Memory pruning means old completed tasks are deleted (no infinite history)
Implementation
Defined ingrip/tools/spawn.py. Uses:
SubagentManagerto track all spawned agentsasyncio.create_task()for background executionuuid.uuid4()for unique ID generation- Automatic status tracking (running → completed/failed/cancelled)
- LRU-style pruning of completed agents (keeps last 50)