A Tour of Multi-Agent Patterns (Router/Supervisor, Planner-Executor, Critic, Swarm, Blackboard) and When Not to Use Them; Getting Started With LangGraph
Get acquainted with the common patterns for multi-agent systems, get clear on when a single agent is enough and when you actually need multiple agents, and build your first three-node graph with LangGraph.
Today's Goals
- Describe what kind of collaboration structure each of Router/Supervisor, Planner-Executor, Critic, Swarm, and Blackboard is
- Judge whether a business scenario should use a single agent or multiple agents, and explain why
- Build a three-node graph with LangGraph.js and run it successfully once
Yesterday closed on a note: one agent's production form is complete, and support has to triage, check stock, draft a refund proposal, and have the proposal reviewed โ one agent cannot do it all. Week three begins by learning every shape of that division of labor, and then learning to refuse most of them.
Plain-Language Walkthrough
A one-person workshop, and an org chart
A company at the very start is one person: pitching clients, writing proposals, delivering, invoicing. That state is extremely efficient because there is no communication cost at all โ every piece of information is in one head. Only when the business outgrows one person does hiring start, and with it roles, processes, and an org chart.
But you have surely seen the other kind of company: eight roles created for work three people could finish, three sign-offs for every decision, and nobody accountable for the outcome in the end. Hiring sometimes solves a problem and sometimes only converts one person's confusion into three people's communication cost. That sentence is the ground color of everything today.
First, what "one person cannot keep up" looks like in practice. Up to W2 our e-commerce support agent looks like this: one system prompt demanding both that it "check refund rules strictly and not promise lightly" and that it "sound warm and try to retain the customer"; twelve tools attached, of which query_order and query_refund are easy to confuse from the names alone; and a user asking "can I return this order" requires the model to recognize intent, pick the right tool, obey the refund rules, and still sound human.
The result is predictable: the prompt grows longer and every rule added dilutes another's weight; the tool-misselection rate rises with tool count; and worst, you cannot localize a problem โ the answer is wrong and you do not know whether intent was misread, the wrong tool was chosen, or the rules were overridden by the "retain the customer" line. The whole prompt is a black box you can only rewrite and retest wholesale.
Multi-agent, at bottom, cuts that black box into pieces so each piece has its own responsibility, its own prompt, and its own failure mode. There are five classic shapes:
- Router / Supervisor: one node decides who should take this case and hands it to the matching subagent, one at a time. Suits tasks that need one expert at a time and whose difficulty is deciding whom to ask. This is the most used one, and tomorrow (D16) is entirely about it.
- Planner-Executor: one node splits a large task into several mutually independent smaller ones, several executors finish them in parallel, and somebody assembles the results into one deliverable. Suits tasks that must be split into several pieces with no ordering between them.
- Critic: the executor's output goes to a reviewer, is bounced back if it fails and released if it passes. Suits tasks where the output's correctness has a definite criterion and redoing it is cheaper than shipping it wrong. Planner-Executor and Critic usually come together, and D17 assembles them into one chain.
- Swarm: no central node, and whoever holds the baton decides who gets it next. Suits exploratory tasks where the global order cannot be stated in advance. The cost is that you do not know in advance how many steps it will take, so neither cost nor latency has a ceiling.
- Blackboard: participants do not know each other exists and only see one shared state: whoever spots something on the board they can handle carries on writing. Suits situations where participants come and go often and you do not want to edit orchestration logic for each one.
Memorizing those five names is pointless. What transfers is this: the difference between patterns is not the name, it is the shape of the graph. Watch four things and the five separate themselves โ is there a branch (one of three at runtime), a fan-out (handed to several at once), a join (several outputs merged), and a back edge (can be bounced for a redo).
// Edges come in two kinds: always is unconditional (all taken), choice is conditional
// (only one taken at runtime). Counting them separately is what reveals the fundamental
// difference between "hand it to three people at once" and "pick one of three".
const critic = {
name: 'Critic',
edges: [
{ from: 'START', to: 'executor', kind: 'always' },
{ from: 'executor', to: 'critic', kind: 'always' },
{ from: 'critic', to: 'executor', kind: 'choice' }, // back edge: bounce for a redo
{ from: 'critic', to: 'END', kind: 'choice' },
],
}
function analyzeShape(pattern) {
// START naturally has one outgoing edge and END naturally takes many incoming ones;
// without excluding them all five patterns look identical
const tally = (pick, kind, skip) => {
const acc = new Map()
for (const e of pattern.edges) {
if (e.kind !== kind || pick(e) === skip) continue
acc.set(pick(e), (acc.get(pick(e)) ?? 0) + 1)
}
return [...acc.values()].some((n) => n > 1)
}
return {
branch: tally((e) => e.from, 'choice', 'START'),
fanOut: tally((e) => e.from, 'always', 'START'),
join: tally((e) => e.to, 'always', 'END'),
}
}from collections import Counter
from dataclasses import dataclass
@dataclass
class Edge:
frm: str
to: str
kind: str # "always" all taken; "choice" only one taken at runtime
CRITIC = [
Edge("START", "executor", "always"),
Edge("executor", "critic", "always"),
Edge("critic", "executor", "choice"), # back edge: bounce for a redo
Edge("critic", "END", "choice"),
]
def analyze_shape(edges: list[Edge]) -> dict[str, bool]:
# START naturally has one outgoing edge and END takes many incoming ones;
# without excluding them all five patterns look identical
def over_one(values) -> bool:
return any(n > 1 for n in Counter(values).values())
return {
"branch": over_one(e.frm for e in edges if e.kind == "choice" and e.frm != "START"),
"fan_out": over_one(e.frm for e in edges if e.kind == "always" and e.frm != "START"),
"join": over_one(e.to for e in edges if e.kind == "always" and e.to != "END"),
}// Dependencies: JDK 17+ records and the Stream API, no third-party library
enum Kind { ALWAYS, CHOICE } // ALWAYS all taken; CHOICE only one at runtime
record Edge(String from, String to, Kind kind) {}
record Shape(boolean branch, boolean fanOut, boolean join) {}
static final List<Edge> CRITIC = List.of(
new Edge("START", "executor", Kind.ALWAYS),
new Edge("executor", "critic", Kind.ALWAYS),
new Edge("critic", "executor", Kind.CHOICE), // back edge: bounce for a redo
new Edge("critic", "END", Kind.CHOICE));
// Stream's groupingBy plus counting expresses "count edges grouped by endpoint" exactly,
// with no hand-written map accumulation
static boolean overOne(List<Edge> edges, Kind kind, Function<Edge, String> pick, String skip) {
return edges.stream()
.filter(e -> e.kind() == kind && !pick.apply(e).equals(skip))
.collect(Collectors.groupingBy(pick, Collectors.counting()))
.values().stream().anyMatch(n -> n > 1);
}
static Shape analyzeShape(List<Edge> edges) {
// START naturally has one outgoing edge and END takes many incoming ones
return new Shape(
overOne(edges, Kind.CHOICE, Edge::from, "START"),
overOne(edges, Kind.ALWAYS, Edge::from, "START"),
overOne(edges, Kind.ALWAYS, Edge::to, "END"));
}enum Kind { case always, choice } // always all taken; choice only one at runtime
struct Edge {
let from: String
let to: String
let kind: Kind
}
struct Shape {
let branch: Bool
let fanOut: Bool
let join: Bool
}
let critic = [
Edge(from: "START", to: "executor", kind: .always),
Edge(from: "executor", to: "critic", kind: .always),
Edge(from: "critic", to: "executor", kind: .choice), // back edge: bounce for a redo
Edge(from: "critic", to: "END", kind: .choice),
]
// Swift's Dictionary(grouping:by:) groups in one step, with no empty dictionary to fill
func overOne(_ edges: [Edge], _ kind: Kind, _ pick: (Edge) -> String, skip: String) -> Bool {
let picked = edges.filter { $0.kind == kind && pick($0) != skip }.map(pick)
return Dictionary(grouping: picked, by: { $0 }).values.contains { $0.count > 1 }
}
func analyzeShape(_ edges: [Edge]) -> Shape {
// START naturally has one outgoing edge and END takes many incoming ones
Shape(
branch: overOne(edges, .choice, { $0.from }, skip: "START"),
fanOut: overOne(edges, .always, { $0.from }, skip: "START"),
join: overOne(edges, .always, { $0.to }, skip: "END"))
}Run it and you see: Router has only a branch, Planner-Executor is a fan-out plus a join, Critic is a branch plus a back edge. Interestingly Critic and Swarm produce the same four booleans โ not a failure of the criteria, but their difference lying in who decides the back edge: Critic has a fixed reviewer node deciding whether to bounce, and Swarm has whoever holds the baton deciding who gets it next. Where shape cannot separate them, the criterion needs a sentence of plain language.
You can now translate any multi-agent paper's architecture diagram into those four booleans. But the genuinely hard question is unanswered: should the requirement in front of you be split at all?
Interview questions
What are the common multi-agent collaboration patterns, and what shape of task suits each?ๅธธ่ง็ๅค Agent ๅไฝๆจกๅผๆๅชไบ๏ผๅๅซ้ๅไปไนๅฝข็ถ็ไปปๅก๏ผ
Common in ChinaCommon overseasBasic#multi-agent#orchestration#architecture๐ Unlock this chapter to see the answer keys.
In LangGraph, what roles do nodes, edges and state play? If you had no framework, how would you implement it yourself?LangGraph ้่็นใ่พนใ็ถๆๅๅซๆฎๆผไปไน่ง่ฒ๏ผๅฆๆไธ็จๆกๆถ๏ผไฝ ่ชๅทฑไผๆไนๅฎ็ฐ๏ผ
Common in ChinaCommon overseasIntermediate#langgraph#orchestration#state-management๐ Unlock this chapter to see the answer keys.
What signals typically trigger the move from a single agent to a multi-agent system, and what does the upgrade cost you?ไปๅ Agent ๅ็บงๅฐๅค Agent๏ผ้ๅธธๆฏ่ขซไปไนไฟกๅท่งฆๅ็๏ผๅ็บงไนๅ็ณป็ปไผๅคไปๅบไปไน๏ผ
Common in ChinaCommon overseasIntermediate#multi-agent#cost#architecture๐ Unlock this chapter to see the answer keys.
When should you not introduce a multi-agent system? Give operational criteria, not it depends.ไปไนๆ ๅตไธไธๅบ่ฏฅๅผๅ ฅๅค Agent ็ณป็ป๏ผ่ฏท็ปๅบๅฏๆไฝ็ๅคๆฎ๏ผ่ไธๆฏใ่งๆ ๅต่ๅฎใใ
Common in ChinaCommon overseasDeep dive#multi-agent#architecture#trade-offs๐ Unlock this chapter to see the answer keys.
