Skip to content

API Reference parrot.tools.spawn

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.spawn

View source

SpawnSubAgentTool — ephemeral sub-agent spawner (FEAT-208).

Provides a first-class tool that an agent can invoke to:

  1. Spawn an ephemeral sub-agent with a restricted tool subset.
  2. Execute a single task with a configurable timeout.
  3. Tear down the sub-agent unconditionally (success, error, or timeout).

The tool orchestrates the existing BotManager lifecycle methods (generalized for typed ownership by TASK-1387/TASK-1388): create_ephemeral_user_bot → poll phase=="ready" → invoke(timeout) → discard.

Usage::

tool = SpawnSubAgentTool(
    bot_manager=app["bot_manager"],
    owner_id="agent:my-orchestrator",
    allowed_tools=["search_docs", "get_weather"],
)
result = await tool.execute(
    task="Summarize the latest market news.",
    tools=["search_docs"],
    timeout=60,
)

Alias AbstractTool

Re-exported from parrot.tools.abstract.AbstractTool.

Class SpawnSubAgentInput

Input schema for SpawnSubAgentTool.

Fields:

Field Type Default Description
task str The question / task for the ephemeral sub-agent.
tools List[str] Allowed tool names for the sub-agent. Intersected with the parent's allowed_tools allowlist for defense in depth.
model Optional[str] None LLM model override. Inherits parent default when not set.
system_prompt Optional[str] None System prompt injected into the sub-agent.
timeout int 120 Max seconds the sub-agent is allowed to run before the call is cancelled. Defaults to 120 s.
ttl_seconds int 300 Ephemeral registry TTL. Keep short (default 300 s / 5 min) for sub-agents — they should be discarded well before this.

Class SpawnSubAgentTool

Spawn an ephemeral sub-agent to execute a single task.

Creates a short-lived sub-agent owned by the calling agent, executes one task with a restricted tool subset and a timeout, then discards the sub-agent — regardless of success, error, or timeout.

The tool never calls promote_user_bot; all sub-agents are ephemeral and discarded after their task completes.

Parameter Type Default Description
bot_manager Any The BotManager instance (injected via constructor — testable without an aiohttp app).
owner_id str Canonical string ID of the parent agent that owns the sub-agent (e.g. "agent:orchestrator-001").
allowed_tools Optional[List[str]] None Allowlist of tool names the parent authorises for sub-agents. The sub-agent receives only the intersection of this list and the tools requested in the call.
name str 'spawn_sub_agent' Tool name (default: "spawn_sub_agent").
description Optional[str] None Tool description override.
routing_meta Optional[Dict[str, Any]] None Routing hints for the CapabilityRegistry. The key "requires_grant" is reserved for future HITL grant enforcement (FEAT-grants); set but not enforced here.

Attributes:

Attribute Type Description
name str
description str

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally