Open this lesson in your favourite AI. It'll walk you through the why, explain the demo, and quiz you on the try-it list.
Some multi-agent systems coordinate through a shared memory or 'blackboard' — a common store agents read from and write to. It's powerful for loosely-coupled collaboration but dangerous for context: an unbounded blackboard becomes a dumping ground that every agent's window must absorb. Managing a blackboard is context engineering at the team level: structure it, scope reads, bound writes, and compress it over time. Knowing when a blackboard helps (genuinely shared evolving state) vs. when explicit hand-offs are cleaner is a key architectural judgment.
The demo implements a bounded, structured blackboard: agents post structured entries, readers query by relevance/tag rather than reading everything, and a compaction step keeps it from growing without limit.
Use these three in order. Each builds on the one before.
What is a blackboard/shared-memory pattern in multi-agent systems, and what's the context risk?
Explain how to keep a shared blackboard from becoming a context dumping ground: structure, scoped reads, bounded writes, and compaction.
When should I use a shared blackboard vs. explicit hand-offs for agent coordination? Design a bounded, structured blackboard that scales to many agents without exploding any single agent's context.
class Blackboard:
def __init__(self, max_entries=50):
self.entries = []; self.max = max_entries
def post(self, agent, tag, text):
self.entries.append({"agent": agent, "tag": tag, "text": text})
if len(self.entries) > self.max:
self.entries = self.entries[-self.max:] # bound it (or summarize oldest)
def read(self, tags): # scoped read, not 'everything'
return [e for e in self.entries if e["tag"] in tags]
bb = Blackboard()
bb.post("scout", "finding", "Competitor cut prices 10%")
bb.post("scout", "noise", "weather is nice")
print(bb.read(tags={"finding"})) # readers pull only what they needpython3 main.py