DESIGNING HARNESSES

Subagents

Hierarchical delegation pattern — a root Agent spawns child sandboxes on demand, coordinates via a mailbox Service, and synthesizes verified findings.

Subagents is the hierarchical delegation pattern. Use it when one coordinator (/root) should break a goal into scoped subtasks, spawn isolated child Agents on demand, guide or interrupt them, and merge their results into a final deliverable.

How it is designed

1. Services

One host-owned collaboration Service manages:

  • Member tree: spawns and tracks child Agents (spawn_child, list_children, stop_child) with depth and concurrency caps enforced on the host.
  • Non-waking mailbox: routes structured messages between parent and children (send_message, read_messages) with authenticated sender IDs.

2. Profiles & Permissions

  • root Profile: can spawn/stop children, message them, and write the final synthesized output (such as report.md).
  • child Profile: receives a private workspace copy, works only on its assigned slice, and reports concrete findings back through the mailbox. Children can be read-only for inspection tasks or writable for isolated edits.

3. Orchestration & Events

  • The Harness spawns /root and subscribes to runtime.onEvent().
  • When a child finishes its turn or posts a mailbox message, the Harness wakes /root (or delivers a non-waking note if /root is busy) so /root can cross-check findings, spawn follow-up children, or steer/interrupt a child that goes off track.
  • Bounded per-turn and overall timeouts prevent hung waits; runtime.close() archives the entire tree and exports required artifacts.

Try or eject it

anyswarm eject subagents --dir ./my-subagents
cd ./my-subagents
npm install
npm start -- --config ./handoff-config.ts --cwd /path/to/repo \
  --prompt 'Split repository inspection across two children and write report.md.' \
  --output-dir ./runs
anyswarm trace --root ./runs --port 8787

Good starting point for: repository audits, multi-module code reviews, split-and-merge research reports, and any workflow with a clear parent/child hierarchy.