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.
A single agent has one context window you manage. A multi-agent system has many windows, and the hard part becomes what each agent sees, what it shares, and what it must never see. Naively giving every agent the full shared history reproduces the single-agent context-bloat problem N times over and leaks information across roles. The discipline shifts from 'manage one window' to 'design an information architecture across agents' — who knows what, when, and why. Getting this wrong causes both runaway cost and subtle correctness bugs where one agent acts on another's half-finished reasoning.
The demo models two agents with deliberately scoped contexts: a researcher that sees raw sources, and a writer that sees only the researcher's distilled findings — not the raw dump. Scoping context per role is the foundational multi-agent move.
Use these three in order. Each builds on the one before.
Why is managing context across multiple agents a harder problem than managing one agent's context window?
Explain context scoping in a multi-agent system: how giving each agent a limited view (rather than full shared state) controls cost and prevents information leakage.
Design the information architecture for a 4-agent pipeline (researcher, planner, writer, reviewer): what each sees, what's shared vs. private, and how I'd enforce the boundaries.
# Each agent gets a CONTEXT SCOPE, not the whole shared state.
researcher_ctx = {"role": "researcher", "can_see": ["raw_sources", "task"]}
writer_ctx = {"role": "writer", "can_see": ["findings", "task"]} # NOT raw_sources
shared = {"task": "Summarize the Q2 risks.",
"raw_sources": ["...50k tokens of documents..."],
"findings": None}
def researcher(shared):
# sees raw_sources, produces compact findings
shared["findings"] = "Top risks: supply delay, FX exposure, churn uptick."
return shared
def writer(shared):
# sees ONLY findings + task — never the 50k-token raw dump
return f"Report on '{shared['task']}': {shared['findings']}"
print(writer(researcher(shared)))python3 main.py