Skip to main content

Module spawn

Module spawn 

Source
Expand description

Spawn Agent Tool (MVP 8 Phase 2)

Internal tool for recursive agent spawning. Allows an agent to delegate subtasks to child agents, enabling hierarchical task decomposition.

§Depth Limit

To prevent infinite recursion, each spawn tracks depth and enforces limits:

  • Default limit: 3 levels
  • Maximum limit: 10 levels
  • Spawning at max depth returns an error

§Events

Spawning emits an AgentSpawned event with:

  • parent_task_id: The spawning agent’s task ID
  • child_task_id: The new agent’s task ID
  • depth: Current recursion depth

§rig::ToolDyn Integration

SpawnAgentTool implements rig::tool::ToolDyn for seamless integration with RigAgentLoop. When an agent has depth_limit > current_depth, the spawn_agent tool is automatically added to its tool list.

§Example

{
  "task_id": "subtask-1",
  "prompt": "Generate the header section",
  "context": {"entity": "qr-code"},
  "max_turns": 5
}

Structs§

SpawnAgentParams
Parameters for spawning a child agent
SpawnAgentTool
Internal tool for spawning sub-agents

Enums§

SpawnAgentError
Errors that can occur when spawning agents