Module 2 · Orchestration topologies
Blackboard and shared memory
5 min read
The blackboard is one of the oldest patterns in artificial intelligence: several experts read and write on a shared space, each contributing when they have something useful to add. Modern multi-agent systems keep reinventing it — LangGraph's shared state is one form of it. Designing it well avoids some of the nastiest bugs: concurrent writes, overwritten data, polluted context.
Shared state is a blackboard
In LangGraph, the State object is read by every node and each node writes updates to it. It's a blackboard with explicit rules:
- each key has a type;
- each key has a merge policy (the reducer) saying how to combine several writes;
- nodes run in the same step (in parallel) write simultaneously.
The concurrent write problem
What happens when two parallel researchers write the same key without a reducer? Let's test it:
class Bad(TypedDict):
items: list[str]
result: str # no reducer
def worker(task):
return {"result": f"done:{task['x']}"}
LangGraph refuses to choose arbitrarily:
langgraph.errors.InvalidUpdateError: At key 'result': Can receive only one value per step.
Use an Annotated key to handle multiple values.
This is healthy behavior: rather than silently keeping the last write (and losing the others' work), the framework forces you to declare how to merge.
Reducers: declaring the merge policy
A reducer is a function (old_value, new_value) → merged_value, attached to the key via Annotated:
import operator
from typing import Annotated
def merge_dicts(left: dict, right: dict) -> dict:
return {**left, **right}
class Good(TypedDict):
items: list[str]
result: Annotated[dict, merge_dicts] # each worker adds its key
findings: Annotated[list[dict], operator.add] # list concatenation
With merge_dicts, two parallel workers returning {"a": "done"} and {"b": "done"} produce {"a": "done", "b": "done"}.
Choosing the right reducer
| Need | Reducer |
|---|---|
| Accumulate results | operator.add on a list |
| One result per agent, addressable | Dict merge keyed by agent |
| Message history, with update by ID | add_messages (provided by LangGraph) |
| Keep the maximum, the latest… | Custom function |
| A single value, a single writer | No reducer (overwrite) |
A custom reducer: deduplicating sources
Several researchers often cite the same documents. A reducer can guarantee uniqueness while preserving order:
def union_sources(left: list[str], right: list[str]) -> list[str]:
seen = set(left)
return left + [s for s in right if not (s in seen or seen.add(s))]
class State(TypedDict, total=False):
sources: Annotated[list[str], union_sources]
A reducer must be pure (no side effects), fast, and ideally associative: the arrival order of parallel writes is not guaranteed, and the result must not depend on it.
Organizing the board: public, private, ephemeral
A blackboard where everyone writes everywhere quickly becomes unreadable. Three hygiene rules:
1. One writer per key (unless there's an explicit reducer)
Document who writes each key. In Atlas: plan is written by the planner alone, draft by the writer alone, findings by all researchers (hence the reducer). A key written by several nodes without a clear reason is a red flag.
2. Separate the public board from the scratchpad
An agent doesn't have to expose all its intermediate reasoning to the others. The Atlas researcher reads three full documents, but only writes a compact Finding to the board (sub-question, summary, source IDs). The raw documents stay within its own call and don't pollute the writer's context.
That's the difference between shared state (what others need to know) and local state (what I need to do my job).
3. Distinct input and output schemas
LangGraph lets you declare input and output schemas that differ from the internal state:
builder = StateGraph(State, input_schema=QuestionInput, output_schema=BriefOutput)
The caller only provides the question and only receives the final note; working keys (plan, review, revisions) stay internal. Your public API doesn't change when you reorganize the board.
Memory beyond a single run
The graph state lives for the duration of one execution thread, persisted by the checkpointer. For memory shared across runs — a user's preferences, facts learned across projects — LangGraph provides a key-value store organized in namespaces:
from langgraph.store.memory import InMemoryStore
store = InMemoryStore() # in production: a database-backed store
store.put(("users", "u-42", "preferences"), "style", {"tone": "concise", "language": "en"})
items = store.search(("users", "u-42", "preferences"))
The namespace (a tuple) provides partitioning: an agent only reads the namespaces that concern it. It's a long-term blackboard — with the same hygiene rules: who writes what, when, and who is allowed to read.
Key takeaways
- LangGraph's shared state is a blackboard: typed keys, one merge policy per key.
- Without a reducer, parallel writes to the same key raise
InvalidUpdateError: a protection, not a bug.- Pick the reducer for the need (concatenate, merge by key, deduplicate); keep it pure and order-independent.
- One writer per key, compact summaries rather than raw data, input/output schemas distinct from internal state.
Hands-on
- Add a
sourceskey to Atlas's state with theunion_sourcesreducer, fed by each researcher. - Write a test that runs 5 researchers in parallel and checks that no source appears twice.
- Declare an
input_schemaand anoutput_schemafor Atlas, and check thatinvokeonly returns the note and its status.