Coordinate via shared state
The orchestrator gathered independent results and the vote aggregated parallel opinions — but those workers never needed to see each other's output. Many real jobs aren't like that. A planner can't decide until the analyst has crunched the numbers; a reporter can't write the summary until the planner has decided. The work is a chain of dependencies. Wire that with direct calls — analyst calls planner calls reporter, each passing its piece as an argument — and the plumbing explodes: every new agent means new arguments threaded through every caller.
The cleaner pattern is a blackboard: one shared state object every agent reads from and writes to. Agent A posts a fact; agent B reads it and posts another derived from it; agent C reads both and writes the conclusion. No agent calls another directly — they leave notes on the same board, in order, and coordination emerges from the shared surface.
Trace the build. The board starts as { revenue: 1200, cost: 800 }. The analyst
writes profit = 400. The planner reads board.profit, sees it's positive, and
writes decision = "invest". The reporter reads both prior facts and writes
summary = "invest because profit 400". Each agent stands on the work of the last
— but only because they share the same object reference. The starter's bug is
exactly this: it hands each agent its own {}, so the planner reads board.profit
as undefined and the chain silently collapses.
Shared state is the wiring of any agent team, and where the subtle bugs live: copy the board instead of sharing the reference and writes vanish; let two agents write the same key and order decides the winner. Get the threading right and the system composes — add a fourth agent later and it just reads the board.
Below, an analyst computes profit, a planner reads that profit to make a
decision, and a reporter reads both to write a summary. Thread the same
board through all three. Done looks like each agent printing what it wrote and a
final board carrying every fact: profit, decision, and summary.
Shared state is the wiring of a multi-agent system: the value of one agent's work is only realized when the next agent can read it.