# The Supervisor Pattern — LangGraph Agents & Multi-Agent Systems

Source: https://www.geekswithgeeks.com/en/langgraph-agents/x-supervisor

> Let one coordinator route work to specialist workers.

## A manager and specialists

In the **supervisor** pattern one agent (often an LLM with a short routing prompt, or plain code) looks at the task and the progress so far and chooses which **worker** acts next, or decides the job is done. Workers do their specialised step and report back to the supervisor, which keeps the overall control flow. This is easy to reason about because every hand-off passes through one place where you can log, limit and approve it. In LangGraph the supervisor is a node that returns `Command(goto=worker)`, and each worker returns `Command(goto="supervisor", update=...)`. Give the supervisor a clear **finish condition** and a step cap.

## A supervisor and two workers, run

I ran this offline with langgraph 1.2.12 and langchain-core 1.6.6 in a Python virtual environment. No API key or model is needed because plain Python functions stand in for the model, so the output is repeatable. This is the same graph as the Command example in the control-flow section: tasks containing "find" go to the researcher, others to the writer, and the supervisor ends the run when a result exists.

```python
from typing import Literal, TypedDict
from langgraph.graph import StateGraph, START, END
from langgraph.types import Command

class State(TypedDict):
    task: str
    result: str

def supervisor(state) -> Command[Literal["researcher", "writer", "__end__"]]:
    if not state.get("result"):
        return Command(goto="researcher" if "find" in state["task"] else "writer")
    return Command(goto=END)

def researcher(state) -> Command[Literal["supervisor"]]:
    return Command(update={"result": "facts about " + state["task"]}, goto="supervisor")

def writer(state) -> Command[Literal["supervisor"]]:
    return Command(update={"result": "draft for " + state["task"]}, goto="supervisor")

g = StateGraph(State)
g.add_node("supervisor", supervisor); g.add_node("researcher", researcher); g.add_node("writer", writer)
g.add_edge(START, "supervisor")
app = g.compile()
for task in ("find the 2025 leave policy", "write a welcome note"):
    print(task, "->", app.invoke({"task": task, "result": ""})["result"])

```

Output:

```
find the 2025 leave policy -> facts about find the 2025 leave policy
write a welcome note -> draft for write a welcome note
```

**Quiz:** In the supervisor pattern, who keeps overall control flow?

- [ ] Nobody
- [ ] Each worker independently
- [ ] The user's browser
- [x] The supervisor

*Answer:* The supervisor. Workers report back; the supervisor decides what happens next.
