Supervisor API Reference¶
Supervisor¶
Multi-agent orchestrator that routes work between named agent graphs.
Constructor¶
The router function receives a SharedState and returns:
- The name of an agent to dispatch to, OR
- The finish marker string ("FINISH" by default) to stop
Methods¶
| Method | Returns | Description |
|---|---|---|
add_agent(name, graph) |
None |
Register a named agent graph (StateGraph) |
max_rounds(rounds) |
None |
Set max routing rounds (default: 10) |
finish_marker(marker) |
None |
Set finish marker string (default: "FINISH") |
run(state) |
SharedState |
Run the supervisor loop |
agent_names() |
list[str] |
List registered agent names |
Behavior¶
- Calls the router with current state
- Router returns next agent name (or finish marker)
- Agent graph runs via
invoke()with current state - Updated state goes back to the router
- Repeats until finish marker or max rounds exceeded
- Raises
RuntimeErrorif max rounds exceeded