Zenaique

What create_supervisor gives you on top of raw LangGraph state machine code

Flashcard·Easy·4.0 · 0·~30s·Asked atAdaBainXai
Attempt it
TL;DR

create_supervisor is a wiring shortcut for the supervisor and workers shape, with a pre-baked routing prompt; under the hood it is the same StateGraph you would write by hand.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Think of it like the meal-kit version of a recipe. The full recipe is in the cookbook, with every step from raw ingredients up. The meal kit hands you pre-measured ingredients and a one-page card that says 'mix, cook, serve'. You can still cook the full recipe from scratch any time you want something the kit does not cover. create_supervisor is the meal kit for the supervisor plus workers shape: it pre-measures the nodes, the routing prompt, and the edges so you do not type them by hand.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Prebuilts in LangGraph are deliberately small. They package the most common topologies as one-call constructors so you do not have to rewrite the same wiring on every project. create_supervisor is the canonical example: it covers the supervisor and workers shape, which is probably 60 to 70 percent of multi-agent code in the wild.

Knowing what the prebuilt does and what it does not is a tidy way to demonstrate fluency with the underlying StateGraph model. If you can articulate the exact nodes and edges it generates, you can also write the same topology by hand the moment the prebuilt stops fitting.

Mental model: the prebuilt is wiring sugar plus a routing-prompt template. Under the hood it is a normal compiled graph with all of LangGraph's persistence and interrupt features intact.

What the prebuilt actually wires

The shape it generates

Given a list of worker agents and a supervisor model, create_supervisor builds:

  1. A StateGraph over a state schema with at minimum a messages channel and a next channel for routing.
  2. One node per worker. The node body is the worker's agent loop (model call plus tool execution), wrapped so its output appends to messages and the control returns to the graph.
  3. A supervisor node whose body runs an LLM call with the routing prompt against messages plus the agent roster, parses the model's output into one of {worker_1, ..., worker_N, FINISH}, and writes the result to the next channel.
  4. A conditional edge from supervisor keyed on next, mapping each worker name to that worker's node and FINISH to the graph's terminal node.
  5. An unconditional edge from each worker node back to supervisor.

Compile it (optionally with a checkpointer and interrupt_before list) and you have a runnable graph.

Why this is a non-trivial chunk of code by hand

The conditional-edge mapping has to enumerate every worker name. The routing prompt has to list them, instruct the model on output format, and enforce that the response is one of the listed names. The state schema needs both a message channel with the right reducer and a routing channel. Getting any of these subtly wrong silently breaks routing. The prebuilt encodes the conventions so you do not.

What it pre-bakes that matters most
When to drop down to raw StateGraph
How it compares to the same idea in other frameworks
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
python
from langgraph_supervisor import create_supervisor
from langgraph.checkpoint.memory import MemorySaver
from langchain_anthropic import ChatAnthropic

model = ChatAnthropic(model="claude-sonnet-4-5")

researcher = ...  # any LangGraph-compatible agent
writer     = ...  # any LangGraph-compatible agent

app = create_supervisor(
    agents=[researcher, writer],
    model=model,
    prompt="Route work between researcher and writer. Reply FINISH when done.",
).compile(checkpointer=MemorySaver())

# Behaves like any other compiled LangGraph: streaming, thread_id, interrupts.

Real products, models, and research that use this idea.

  • LangGraph's official multi-agent tutorial uses create_supervisor for the canonical research and write team.
  • LangChain's `langgraph-supervisor` package extracts the prebuilt for stand-alone use across LangChain agents.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow would you implement parallel fan-out across workers if the prebuilt is sequential?
A

Drop to raw StateGraph. Use the Send API to dispatch from the supervisor to N workers in one tick, give the state a list-reducer on messages, and add a synthesiser node that consumes the merged list. The supervisor then routes to the synthesiser or to another round.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating create_supervisor as a different runtime. It is not; it produces a regular compiled StateGraph that you can inspect, extend, and checkpoint like any other.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • What nodes and edges the prebuilt sets up under the hood

  • Why the pre-baked routing prompt is the highest-leverage piece

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Why AutoGen 0.4 makes TerminationCondition a first class primitive instead of leaving it to convention
Flashcard·Medium