When to reach for it
- Tasks are open-ended, multi-step, and tool-intensive.
- Multiple specialists must operate with high autonomy over long horizons.
Plan. Delegate. Synthesize. Over long horizons.
An orchestra of specialized agents combines planning, a task ledger, delegation, and replanning for long-running, complex goals.
A planner-supervisor maintains a task ledger, delegates to specialists, and synthesizes results across long-running goals.
| Step | Orchestrator | Agent | Ledger |
|---|---|---|---|
| 1 | Writes the plan: search, collect counts, draw the chart | None | A plan, no facts yet |
| 2 | Sends the search | Web agent | Three paper titles |
| 3 | Asks for the citation counts | Web agent | Blocked: the site wants a login |
| 4 | Sees no progress twice and rewrites the plan | None | New plan: query an open API |
| 5 | Has the query run and the chart drawn | Coding agent | Counts and chart. Done |
def magentic(goal, agents, max_steps=20, max_stalls=2):
ledger = {"facts": [], "plan": model(PLAN, goal)} # the task ledger
stalls = 0
for _ in range(max_steps):
# done? progressing? who is next?
check = model(PROGRESS, goal, ledger)
if check.done:
return model(FINAL_ANSWER, goal, ledger)
stalls = 0 if check.progressing else stalls + 1
if stalls >= max_stalls: # stuck: rewrite the plan
ledger["plan"], stalls = model(REPLAN, goal, ledger), 0
continue
ledger["facts"].append(agents[check.next_agent](check.instruction))
raise RuntimeError("step budget used up")When to reach for it
When it backfires
The planner keeps adding subtasks without closing existing ones. The ledger becomes an infinite to-do list.
Countermeasure
Require every delegation to include a completion criterion. Close ledger entries explicitly, not by timeout.
A mid-flight replan reassigns a task to a different specialist, but the new specialist lacks the context the first one built.
Countermeasure
Persist intermediate state with each ledger entry. Hand off both the task and the accumulated context.
Next pattern
Search patterns, frameworks, and pages.