Expand description
SpawnSubtask — an agent dynamically spawns isolated, tool-constrained
sub-agents mid-run via a spawn_subtask tool.
Unlike Delegator, which routes to a fixed set of named
specialists, spawn_subtask lets the main agent invent an ephemeral
sub-agent on the fly and hand it a subset of its own tools:
main agent calls spawn_subtask(task="scrape the page", tools=["fetch"])
→ SpawnSubtaskExecutor intercepts
→ validates {fetch} ⊆ parent tools (privilege de-escalation)
→ spawns an ephemeral agent limited to {fetch}
→ returns the sub-agent's answer as the tool result§Tool-subset is enforced twice — once provably
- Schema (provable): the
spawn_subtasktool is registered with a JSON Schema whosetoolsitems are anenumof the parent’s tool names. The runtime’s validator (car-validator, viajsonschema) rejects any proposed call that lists a tool outside that set before execution. The subset constraint is therefore a verified precondition, not a convention. - Executor (defense in depth): the executor re-checks the subset at call time, so a caller that dispatches the tool without schema validation still cannot escalate.
§Parallelism
Multiple spawn_subtask calls a model emits in one proposal run concurrently
through the engine’s DAG executor (futures::join_all over independent
actions) — no manual batching needed. Each spawn gets its own runtime over
the shared infra, so they don’t contend on a single mutable tool.
Structs§
- Spawn
Subtask - Coordinator: runs a main agent with the
spawn_subtasktool enabled. - Spawn
Subtask Result - Result of running an agent that can spawn sub-agents.
- Subtask
Record - Record of one
spawn_subtaskinvocation.
Constants§
- SPAWN_
SUBTASK_ TOOL - Reserved name of the meta-tool itself. Never granted to a sub-agent, so delegation is structurally bounded to one level.
Functions§
- spawn_
subtask_ schema - Build the
spawn_subtasktool schema whosetoolsparameter is constrained to anenumofparent_tools— the verifiable subset precondition.