A single agent can only do so much. Give it a research task, a writing task, and a fact-check in one prompt, and it will mix them up, skip steps, or invent details to fill the gaps. A multi-agent workflow with LangGraph splits that work across specialist agents instead: one plans, one researches, one writes, and a supervisor decides who goes next. Each agent gets a narrow job and the tools for that job only, so mistakes stay local instead of spreading through the whole answer.
This guide walks through the supervisor pattern from scratch: how the supervisor routes work, how workers hand tasks back, how shared state keeps everyone in sync, and a minimal graph you can run and extend.
How a Multi-Agent Workflow with LangGraph Works
LangGraph models an agent workflow as a graph. Nodes do the work, edges decide what runs next, and a shared state object carries messages between nodes. A multi-agent workflow with LangGraph adds one idea on top: some nodes are agents with their own prompts and tools, and one node acts as the supervisor.
Picture a small content team. A researcher gathers sources. A writer turns sources into a draft. A reviewer checks the draft against the sources. The supervisor is the editor who reads the latest output, decides which specialist should act next, and calls the job done when the draft passes review.
The graph makes that loop explicit. When the workflow goes wrong, you can point at the exact node and the exact message that caused the problem, instead of guessing what happened inside one long prompt. If you are still weighing frameworks, this comparison of how LangGraph compares with CrewAI and AutoGen lays out where each one fits.
The LangGraph Supervisor Pattern: Routing, Not Doing
The langgraph supervisor pattern has one rule: the supervisor routes, it does not do the work itself. Its prompt describes the team, the goal, and the routing options. Its only output is a decision about who acts next, or that the task is finished.
Keep the supervisor prompt short. List each worker, what it is good at, and when to pick it. Add a rule for finishing: the conditions under which the supervisor should stop the loop. A supervisor with a vague finishing rule will keep calling workers until it runs out of steps or budget.
One common mistake is giving the supervisor tools of its own. Once it can search the web or run code directly, it starts doing worker jobs badly instead of delegating them. If a task needs a tool, that tool belongs on a worker. This is the same shift described in the guide to what changes when you move from a chatbot to agents: the value comes from splitting responsibilities, not from one component doing more.
Designing Specialist Workers
A good worker has a narrow job, a clear input, and a clear output format. “Research this topic and return five sources with a one-line summary of each” is a worker. “Help with the article” is not.
Give each worker only the tools its job needs. A researcher gets search and fetch tools. A writer gets no tools at all, just the sources in its context. A reviewer gets the draft and the sources, and returns a list of issues. Narrow tool access has two benefits: the agent makes fewer wrong tool calls, and a compromised or confused tool cannot affect parts of the workflow it should never touch.
Workers should also know when to give up. A researcher that cannot find a source should say so and return what it found, not keep searching until the step limit kills the run. A worker that reports failure cleanly is far easier to debug than one that loops silently.
Agent Handoffs: How Agents Pass Work to Each Other
Agent handoffs are the moments where work moves from one agent to the next. In LangGraph, a handoff is usually a node returning a command that names the next node, plus a message added to the shared state. The message is the handoff: it tells the next worker what to do and what has already been done.
There are two handoff styles. In supervisor handoffs, every worker returns control to the supervisor, which picks the next worker. This is simple to reason about and easy to log, and it fits most teams of two to five workers. In direct handoffs, a worker names the next worker itself. That cuts a round trip, but routing logic spreads across every worker prompt, which makes the workflow harder to change later.
Whatever style you pick, make handoffs visible. Log the worker name, the message it produced, and the next node at every step. When a workflow produces a bad result, that log turns a mystery into a short list of suspects.
Shared State: What Every Agent Sees
State is the memory of the graph. In LangGraph, the usual starting point is a messages list that every node can read and append to. The supervisor reads it to route, workers read it for context, and the final answer is usually the last message.
Shared state needs discipline. If every worker appends long tool outputs to the same list, the context grows until the later agents slow down or start ignoring earlier instructions. Keep raw tool output out of the shared messages when you can. Summarize it into the handoff message instead: the researcher returns five summarized sources, not fifty pages of fetched HTML.
For state beyond messages, add fields to the state schema: a plan, a draft, a review checklist. Typed fields beat stuffing everything into chat messages, because workers can read exactly the field they need. The guide to patterns for giving agents memory covers the same trade-off in more depth.
A Minimal Supervisor Graph in Code
The example below is the smallest useful version of the pattern: a supervisor, a researcher, and a writer, sharing a messages list. Fill in search_tool and write_draft with your own functions. Each worker returns a command that updates the state and hands control back to the supervisor, which routes again or ends the run.
from langgraph.graph import StateGraph, MessagesState, START, END
from langgraph.types import Command
def supervisor(state: MessagesState):
last = state["messages"][-1].content.lower()
if "research" in last:
return Command(goto="researcher")
if "draft" in last:
return Command(goto="writer")
return Command(goto=END)
def researcher(state: MessagesState):
result = search_tool(state["messages"][-1].content)
return Command(
update={"messages": [result]},
goto="supervisor",
)
def writer(state: MessagesState):
draft = write_draft(state["messages"])
return Command(
update={"messages": [draft]},
goto="supervisor",
)
graph = StateGraph(MessagesState)
graph.add_node("supervisor", supervisor)
graph.add_node("researcher", researcher)
graph.add_node("writer", writer)
graph.add_edge(START, "supervisor")
app = graph.compile()
Two details matter here. First, the supervisor in this example routes on keywords, which is fine for a first version. In a real workflow you would replace it with a language model call that reads the last message and picks the next worker by name. Second, the graph has no step limit of its own, so set one when you invoke it, for example by passing a recursion limit in the config.
When This Pattern Helps, and When It Does Not
Multi-agent orchestration is mostly a routing problem, and the supervisor pattern pays off when the job genuinely splits into different skills. Research plus writing plus review is a natural split. So is triage plus diagnosis plus fix in a support workflow, or planning plus coding plus testing in a small coding assistant.
It does not pay off for a job one agent already does well. If a single prompt with the right tools returns good results, adding a supervisor adds latency, cost, and new failure modes for no gain. A common test: if you cannot name the workers and their distinct jobs in one sentence each, you do not have a multi-agent problem yet. Start with a single ReAct agent and split it only when you can point at a concrete step where the single agent keeps failing.
Common Mistakes That Break Multi-Agent Workflows
The first mistake is a supervisor with no finish line. Add an explicit stop condition and a hard step cap, and treat hitting the cap as a failure to investigate, not a normal ending.
The second is workers that share one giant prompt. When every agent gets the same long system prompt with a note saying “you are the researcher,” the roles blur and the agents start doing each other’s jobs. Write a separate, short prompt per worker.
The third is untested handoffs. Test each worker on its own with fixed inputs before wiring it into the graph, then test the graph with a small set of real requests and read the full trace. Most multi-agent bugs show up in the handoff messages: a worker that returns the wrong format, a summary that drops a key fact, or a supervisor that misreads a result.
Build the smallest version first: a supervisor, two workers, and a step cap. Run it on real tasks, read the traces, and let the failures tell you what to split or simplify next.