
Orchestrate a Team of AI Agents in 25 Lines: The LangGraph Supervisor Pattern
Chris Harper
2 min read
Aug 16, 2026 · 12:03 UTC
pip install langgraph-supervisor and create_supervisor() gives you a routing orchestrator that delegates to specialist agents — 25 lines of Python, no custom routing logic.
What you'll be able to do after this:
- Build a multi-agent system where a supervisor LLM reads each step and routes to the right specialist
- Use
create_supervisor()to skip hand-coded state machines and transition logic - Add memory and human-in-the-loop checkpointing to the same graph with two extra lines
The pattern: The supervisor is an LLM that reads the current conversation state and calls one of two built-in tools: transfer_to_<agent_name>() (delegate to a specialist) or returns a final response. Each specialist runs its own ReAct loop with its own tools. When the specialist finishes, control returns to the supervisor.
Setup
pip install langgraph-supervisor langchain-anthropic
from langgraph_supervisor import create_supervisor
from langgraph.prebuilt import create_react_agent
from langchain_anthropic import ChatAnthropic
model = ChatAnthropic(model="claude-sonnet-5-20260130")
# Specialist 1: web researcher
researcher = create_react_agent(
model,
tools=[web_search_tool],
name="researcher",
prompt="You search the web and return verified facts. Be concise."
)
# Specialist 2: Python analyst
analyst = create_react_agent(
model,
tools=[python_repl_tool],
name="analyst",
prompt="You run Python code and return computed results with the code used."
)
# Supervisor routes between them
app = create_supervisor(
model,
agents=[researcher, analyst],
prompt=(
"You manage researcher and analyst. "
"Send information-gathering tasks to researcher, "
"and computation tasks to analyst. "
"When both are done, synthesize a final answer."
)
).compile()
# Run it
result = app.invoke({
"messages": [{"role": "user", "content": "What is the population of Tokyo? Calculate how many people that is per square kilometer (area: 2,194 km2)."}]
})
print(result["messages"][-1].content)
Two things that make this practical
State is shared. The researcher's answer goes into the shared messages state, so the analyst can read it in the next step — no custom handoff code.
Memory is one argument. Pass checkpointer=MemorySaver() to .compile() and the graph persists state across invocations for the same thread_id. Multi-turn conversations and human-in-the-loop interrupts use the same API.
The video below walks through a complete version with MCP tool calls, guardrails, observability, and a Streamlit UI — worth watching once you have the basic pattern running.
Sources: Build a Multi-Agent System with LangGraph, MCP, Supervisor, Guardrails — YouTube · LangGraph Agent Supervisor tutorial — LangChain GitHub · langgraph-supervisor — PyPI