Pick a depth. Each prompt opens in your AI pre-loaded with the lesson. Click a row to preview the prompt.
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.
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