Subagent Swarms & Orchestration

Agent Substrate provides built-in multi-agent primitives to coordinate fleets of specialized agents under an overarching supervisor with strict budget governance.


Hierarchical Supervisor Pattern

In a supervisor workflow, an OrchestratorAgent breaks a high-level goal into sub-tasks and delegates them to specialized workers (e.g. a researcher, a coder, and a validator).

python
from substrate.agents import Orchestrator, WorkerAgent

# 1. Define specialized workers
researcher = WorkerAgent(
    name="researcher",
    model="claude-3-7-sonnet",
    system_prompt="You gather technical facts and API documentation.",
    tools=[search_web, query_docs]
)

coder = WorkerAgent(
    name="coder",
    model="claude-3-7-sonnet",
    system_prompt="You write robust Python scripts with tests.",
    tools=[python_sandbox]
)

# 2. Configure the supervisor
supervisor = Orchestrator(
    model="claude-3-7-sonnet",
    workers=[researcher, coder],
    max_turns=20,
    budget_limit_usd=5.00
)

# 3. Execute coordinated workflow
result = await supervisor.run("Research Stripe webhook signature verification and write a Python validator.")

Autonomous Sub-Budget Allocation

When an orchestrator delegates to a subagent:

  • It assigns a strict sub-budget (e.g. Researcher has max $1.00 and 5 steps).
  • If the worker exceeds this threshold, control immediately returns to the orchestrator with an error flag.
  • Prevents runaway sub-processes from consuming the entire organization budget.
Was this page helpful?