The crew

Sub-agents

An agent can hand work to child agents. spawn_agent runs a single child; spawn_agents fans out a batch in parallel. The tree is bounded and safe by construction: depth caps, a child-count cap, an abort cascade, and a completion bridge that wakes the parent when its children settle.

Spawning#

  • spawn_agent — delegate one task to one child and wait for it.
  • spawn_agents — delegate a batch of jobs to run concurrently, joined on a single wake.

A child runs in its own context with a depth-aware preamble that tells it which level of the tree it is on. Results flow back to the parent through the completion bridge.

Caps & defaults#

The tree cannot run away. The defaults:

LimitDefaultNotes
Max depth3How deep the spawn tree may go
Max children per parent5Fan-out width per agent
Timeout300sPer sub-agent wall-clock budget
CleanupkeepSub-agent artifacts are kept by default

These are overridable per-agent under cfg.agents.defaults.subagents.*, or via the BRIGADE_SUBAGENT_MAX_DEPTHenvironment variable. A spawn is rejected when the caller is already at max depth — so leaf agents lose the spawn tools entirely. The 300-second timeout is the in-process policy default; sub-agents routed through the gateway's session tools use a 180-second run timeout unless told otherwise.

Abort cascade & wake#

Two mechanisms keep the tree coherent:

  • Abort cascade — aborting a parent propagates to all of its descendants, so nothing keeps running after you stop a turn.
  • Completion bridge — a debounced, per-parent wake collapses a burst of sibling completions into a single wake of the parent when descendants settle.

The toolset a child receives is also filtered by depth: deeper sub-agents lose privileged tools, so a leaf cannot do something its parent could not authorize.

Visibility

By default an agent only sees its own sessions (visibility: "self"). Set "tree" to let a parent read the sessions of the sub-agents it spawned. See Agents & isolation.