tagmac.dev Free AI-visibility check →

Coordinate LangChain agents with a blackboard (and cut the token bill)

By Tağmaç Çankaya · 9 July 2026

Short answer: a naive multi-agent setup keeps one shared conversation and re-passes the whole thing to every agent every turn, so cost grows with the square of the conversation — and most of those tokens are agents re-reading each other. A blackboard fixes it: each agent sees only its own task plus a bounded digest of a shared board, and leaves a short trace instead of chattering. In our own A/B this cut input tokens ~54% and cost ~65%. Below is a real CairnBlackboardMiddleware you can drop into LangChain.

The problem: agents re-reading each other

Say you point three agents at one task — a performance reviewer, a security reviewer, a DX reviewer. The obvious way to let them "collaborate" is one shared conversation passed to each agent every turn. It works on a toy example and then the token bill detonates: every turn, every agent re-reads everything every other agent already said. The cost scales with the square of the conversation, and most of it isn't thinking — it's re-reading.

The idea: a blackboard, not a group chat

Borrow from how ants coordinate. Instead of talking to each other, agents leave short traces on a shared blackboard, and each agent only ever sees its own task plus a small, bounded digest of the board. No transcript re-passing. Coordination emerges from a shared filter, not from chatter — this is stigmergy.

I packaged this as Cairn, a small framework-agnostic coordination library (a cairn is a stack of stones that marks a path without a word — which is the mechanism). Cairn never calls an LLM; your model makes every call, Cairn only structures how the agents coordinate.

Using it with LangChain

The langchain-cairn package gives you a CairnBlackboardMiddleware. Give every collaborating agent the same board (a file path makes it shared across agents and processes), one middleware instance each with a distinct name:

pip install langchain-cairn
from langchain.agents import create_agent
from langchain_cairn import CairnBlackboardMiddleware

board = "review-board.jsonl"          # file-backed -> shared across agents/processes

perf = create_agent(
    model="gpt-4o-mini", tools=[...],
    middleware=[CairnBlackboardMiddleware(board, agent_name="perf")],
)
sec = create_agent(
    model="gpt-4o-mini", tools=[...],
    middleware=[CairnBlackboardMiddleware(board, agent_name="sec")],
)

Under the hood, the middleware uses two standard LangChain hooks:

The measured delta (ours, honestly)

In a controlled A/B on Cairn's own core — same task, same model, only the context architecture changed — the blackboard style cut input tokens ~54% and cost ~65%.

naive full-contextminimal + blackboardreduction
billable input tokens488,477222,68054%
short-run cost (illustrative)$4.13$1.4465%
Honest limits. Those numbers are from my A/B, not a universal claim — your delta depends on how chatty your naive baseline was (the win is bigger the more your agents re-read each other). A blackboard suits fan-out / parallel-angle work (independent reviewers, multi-source research); a tightly sequential dialogue where each step needs the last verbatim is a different shape. The benchmark harness is in the repo so you can reproduce or falsify it — measure your own.

FAQ

Why do multi-agent LLM setups get so expensive?
The naive pattern re-passes the whole shared conversation to every agent every turn, so cost grows with the square of the conversation — mostly agents re-reading each other.
What is a blackboard here?
A shared surface where agents leave short traces instead of talking. Each agent reads only a bounded digest plus its own task, never the full transcript (stigmergy).
How much does it save?
In our A/B, ~54% input tokens / ~65% cost. Yours depends on baseline chattiness — measure it; the harness is open.
Does it work with LangGraph?
Yes — the middleware attaches the same way; a compiled graph is just another agent with the shared board.
Try it: pip install langchain-cairn · code + benchmark harness at github.com/echo-toolkit/cairn. I build working AI systems and automation at tagmac.dev — analyze → build → hand over. If you run it on a real workload, I'd like to hear the token delta you measure, especially where it doesn't help.