Skip to content

Supervisor API Reference

Supervisor

Multi-agent orchestrator that routes work between named agent graphs.

from flowgentra_ai import Supervisor

Constructor

Supervisor(router: Callable[[SharedState], str])

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

  1. Calls the router with current state
  2. Router returns next agent name (or finish marker)
  3. Agent graph runs via invoke() with current state
  4. Updated state goes back to the router
  5. Repeats until finish marker or max rounds exceeded
  6. Raises RuntimeError if max rounds exceeded