· Engineering · 5 min read
The Agent Supervisor Pattern: Why Your Mesh Needs a Boss
Autonomous agents are prone to infinite reasoning loops and 'democratic' indecision. We explore the Supervisor pattern in LangGraph, MCP, and why orchestration beats choreography.

“Let’s just build a mesh of agents and let them figure it out.”
I hear this a lot. It sounds great on a whiteboard. It’s decentralized, it’s “organic,” and it feels like the future of collaborative intelligence.
But in production, a “mesh” of agents usually looks like a 4:00 PM meeting where no one has an agenda. Agents Researcher and Writer start looping. Writer asks for more data, Researcher finds it, Writer disagrees with the format, and before you know it, you’ve burned $50 in API credits on an infinite conversation about a Markdown header.
If you want agents that actually ship, you need a Supervisor.
The Supervisor Pattern
In the Supervisor pattern, you have one central “Orchestrator” agent and several specialized “Worker” agents.
The user never talks to the workers. The workers never talk to each other. They only talk to the Boss.
The Workflow:
- Intent Analysis: The Supervisor receives the task (e.g., “Write a technical brief on NCCL vs RCCL”).
- Delegation: It decides: “I need a search from the
Researcherand a code snippet from theCoder.” - Review: When the
Researcherreturns, the Supervisor checks the work. “This is too generic. Find the specific latency numbers for NCCL 2.27.” - Aggregation: Once all workers have satisfied the Boss, the Supervisor compiles the final answer.
Implementation: LangGraph vs. Genkit
I’ve been spending a lot of time in LangGraph’s new Supervisor library. It makes this pattern incredibly clean.
Instead of writing complex conditional logic, you define your workers as nodes and the Supervisor as a router that maintains the state of the conversation.
LangGraph: The Graph-Based Supervisor
In LangGraph, the Supervisor is a node in a stateful graph. It decides which worker should take the next turn based on the current state of the dialogue.
from langgraph.prebuilt import create_supervisor
from langgraph.graph import StateGraph
# Define your workers
researcher = create_react_agent(model, tools=[search_tool])
coder = create_react_agent(model, tools=[code_tool])
# The Supervisor orchestrates the workers
supervisor = create_supervisor(
[researcher, coder],
initial_prompt="You are the Boss. Route the task to the right expert."
)
# Build the graph
builder = StateGraph(State)
builder.add_node("researcher", researcher)
builder.add_node("coder", coder)
builder.add_node("supervisor", supervisor)
# The supervisor manages all edges
builder.add_edge("researcher", "supervisor")
builder.add_edge("coder", "supervisor")
builder.set_entry_point("supervisor")
graph = builder.compile()Genkit: The Flow-Based Orchestrator
Google’s Genkit takes a different approach. It leans into the “Flow” metaphor, where the Supervisor acts as a structured router within a strongly-typed execution pipeline.
import { defineFlow, runAgent } from '@genkit-ai/ai';
export const supervisorFlow = defineFlow(
{ name: 'supervisorTask', inputSchema: z.string() },
async (input) => {
// 1. Supervisor analyzes intent
const plan = await runAgent(supervisorAgent, input);
// 2. Supervisor routes to specialized worker
let result;
if (plan.needsResearch) {
result = await runAgent(researcherAgent, plan.query);
} else {
result = await runAgent(coderAgent, plan.codeSpec);
}
// 3. Supervisor validates and returns
return await runAgent(summarizerAgent, result);
}
);Choosing Your Weapon: Cyclic Graphs vs. Linear Flows
The choice between LangGraph and Genkit isn’t just about Python vs. TypeScript; it’s about how you model “thought.”
LangGraph (The Cyclic Approach) LangGraph is built for cycles. In most agentic work, “one-and-done” is a myth. An agent might search, realize it found a broken link, and need to go back and search again. LangGraph’s stateful graph allows these loops to happen naturally.
- Best for: Open-ended reasoning, iterative research, and complex multi-turn dialogues where the path isn’t known upfront.
- The Trade-off: Graphs can become “spaghetti” if you don’t enforce strict Supervisor boundaries.
Genkit (The Linear Approach) Genkit leans into Flows. It treats agentic work more like a traditional backend pipeline with “intelligence” baked into the stages. By forcing a more linear, structured route, you get predictable execution and easier debugging.
- Best for: High-reliability production systems, fixed business logic (e.g., “Analyze support ticket -> Route to Dept -> Generate Reply”), and teams that value type-safety and structured output.
- The Trade-off: Handling complex back-and-forth loops in a linear flow requires more boilerplate code than in a cyclic graph.
The Model Context Protocol (MCP) Factor
The biggest shift in 2026 is how these agents “see” their tools.
Historically, if the Researcher agent needed to check Jira, you had to hard-code a Jira API wrapper into the agent’s logic. If you changed your project management tool to Linear, you had to rewrite the agent.
Now, we use MCP (Model Context Protocol). The Supervisor doesn’t care how a tool works; it only cares that an MCP server is exposing it. MCP creates a standard “handshake” between the model and the context.
It’s the SQL of the agentic era.
Why Orchestration Beats Choreography
In microservices, we talk about Choreography (services reacting to events) vs. Orchestration (a central controller).
For agents, choreography is a nightmare. LLMs are non-deterministic. If Agent A sends a message that Agent B interprets slightly differently than you intended, the whole system drifts into a hallucination.
Orchestration (The Supervisor) gives you a single point of failure-which sounds bad-but it also gives you a single point of debugging.
When the system fails, you look at the Supervisor’s logs. You see exactly where the delegation went wrong. You see exactly which worker failed the “Quality Check.”
Conclusion
Agents are powerful, but they are also “interns with infinite throughput.” If you give them a blank check and a vague goal, they will fail eventually.
Give your agents a boss. Implement a Supervisor. Control the loop, or the loop will control your bank account.


