Expand description
Parallel delegation primitive — spawn N isolated subagents with restricted toolsets and collect their summaries.
Port of _inspirations/hermes-agent/tools/delegate_tool.py. The key
invariants:
- Isolation: child agents start with a fresh conversation — no parent history, own session-id-equivalent.
- Restricted toolset: caller specifies which tools the child may
call. A default blocklist strips dangerous recursion paths
(
delegate, memory writes, user-interaction tools) at depth ≥ 1. - Depth cap:
max_depth = 2(parent = 0, child = 1, no grandchildren) prevents infinite recursion. - Bounded parallelism: up to
max_concurrentchildren run at once viatokio::task::JoinSet. - Best-effort: a child failure doesn’t abort the batch; the parent gets an error summary for that task and keeps going.
This module does NOT pull in a Python RPC bridge for code execution — that’s the 0.1.9 lift.
Structs§
- Delegate
Config - Top-level config for a batch delegation.
- Delegate
Result - Result from one child agent.
- Delegate
Task - Input to a single delegation.
Constants§
- DEFAULT_
MAX_ CONCURRENT - Default in-flight child limit per batch — matches hermes-agent’s
max_concurrent_children. - DELEGATE_
BLOCKED_ TOOLS - Tools whose names match these strings are stripped from the child’s
toolset. These are either recursion hazards (
delegate) or cross-agent side effects (memory writes, user-facing messages). Caller-provided blocklists are merged with this default. - MAX_
DEPTH - Maximum delegation depth (parent=0). Children cannot spawn grandchildren.
Functions§
- build_
child_ system_ prompt - Build the child system prompt. Verbatim port of
_inspirations/hermes-agent/tools/delegate_tool.py::_build_child_system_prompt— paraphrasing costs us the bench parity guarantee. - run_
batch - Run a batch of delegations. Blocks until every child completes (success or failure). On depth exhaustion, returns an error immediately without spawning anything.
Type Aliases§
- Provider
Factory - Function that constructs a fresh provider for each child. Needed because
Providertrait objects aren’t cloneable — each delegated child needs its own provider instance. - Toolset
Factory - Function that constructs a fresh toolset for each child. Same reason as
ProviderFactory—Box<dyn Tool>isn’t cloneable.