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.
In the common orchestrator-workers pattern, the orchestrator holds the big picture (the plan, progress, which workers ran) while each worker holds only its narrow sub-task context. Conflating these — giving workers the full plan or letting the orchestrator accumulate every worker's raw output — defeats the pattern. The orchestrator's context should stay high-level and bounded (a plan + summaries), and workers should be stateless-ish and focused. Keeping these two context levels distinct is what lets the pattern scale to many workers without the orchestrator's window exploding.
The demo separates orchestrator state (plan + per-task status + worker summaries) from worker state (just the sub-task + its inputs). Workers return summaries, not raw output, so the orchestrator's context grows slowly.
Use these three in order. Each builds on the one before.
In the orchestrator-workers agent pattern, how should context differ between the orchestrator and the workers?
Explain why workers should return compact summaries (not raw output) to the orchestrator, and how that keeps the orchestrator's context bounded as worker count grows.
Design the context model for an orchestrator coordinating 50 parallel workers: what the orchestrator tracks, what workers return, and how to avoid the orchestrator's window becoming the bottleneck.
orchestrator = {"plan": ["fetch", "analyze", "write"], "status": {}, "summaries": {}}
def run_worker(subtask, inputs):
# worker sees ONLY its subtask + inputs, returns a compact summary
raw = f"...lots of work output for {subtask}..."
summary = f"{subtask}: done, key result extracted" # distilled, not raw
return summary
for step in orchestrator["plan"]:
summary = run_worker(step, inputs={"step": step})
orchestrator["status"][step] = "done"
orchestrator["summaries"][step] = summary # orchestrator keeps summaries only
print(orchestrator["summaries"]) # bounded, high-level view — never the raw worker outputpython3 main.py