Skip to main content
The Supervisor pattern lets you build multi-agent systems where a parent agent automatically routes requests to specialized child agents. Instead of one agent handling everything, you decompose complex domains into focused specialists — each with its own tools, knowledge base, and instructions.

How It Works

When you add the agents field to an Agent config, the parent becomes a supervisor. It uses an LLM call to analyze the user’s message against each child agent’s instructions and selects the best match.
The routing happens in a single LLM call — the supervisor reads each agent’s name and instructions, compares them to the input, and picks one. If the LLM returns an invalid agent name, Runflow falls back to the first agent in the list.

Basic Setup

Specialist Agents with Tools and RAG

Each child agent can have its own tools, RAG configuration, memory, and model — completely independent from other agents:

Cost Optimization: Cheap Router, Quality Specialists

The supervisor only classifies intent — it doesn’t generate user-facing responses. Use a fast, cheap model for routing and reserve powerful models for the specialists that do the real work:
This pattern can reduce costs by 50-80% compared to using a single powerful model for everything. The supervisor call is fast and cheap — the expensive model only runs for the task that actually needs it.

Routing Logic in Detail

The supervisor builds a prompt like this internally:
The supervisor’s own instructions are used as the system prompt, so you can add domain-specific routing rules:

Shared Memory and Context

Memory is configured on the supervisor and shared across the entire session. If a customer starts with support and then asks about billing, the billing agent has full context of what was discussed:

Observability

The supervisor generates traces automatically. With observability: 'full', you get:
  • Supervisor span: which agents were available, which was selected
  • LLM call span: the routing decision (model, tokens, latency)
  • Child agent span: the full execution trace of the selected agent
  • Tool call spans: every tool the child agent invoked
See Observability for details on trace levels and custom event tracking.

Fallback Behavior

If the LLM returns an agent name that doesn’t match any key in the agents config, Runflow automatically falls back to the first agent in the list. Design your agent order accordingly — put the most general-purpose agent first:

When to Use Multi-Agent vs Single Agent

Supervisor vs Workflow

The SDK offers two patterns for multi-agent orchestration: Use the supervisor when you need simple, intent-based routing. Use Workflows when you need multi-step pipelines with explicit branching, parallel execution, or data transformations.

Configuration Reference

Supervisor Agent

Child Agent (within agents)

Each child agent supports the full AgentConfig:

Next Steps

Multi-Agent Example

Complete real-world example with supervisor + 3 specialists

Tools

Create tools for your specialist agents

Knowledge (RAG)

Add knowledge bases to specialists

Workflows

Multi-step pipelines with explicit routing