Planner-Executor-Critic Plus a Shared Workspace: Workspace State, toolBudget, Parallel Fan-Out, a Review Loop
Build a Planner-Executor-Critic collaboration flow, pass intermediate state through a shared workspace, add a tool budget and parallel execution, then have the Critic check the result and drive a rewrite.
Today's Goals
- Implement a Planner that splits a task into subtasks and writes them into the shared workspace
- Implement an Executor that runs subtasks in parallel while respecting the toolBudget limit
- Implement the full Critic loop that checks the result and bounces it back for a rewrite
Yesterday's Supervisor solved "who takes this case," and it dispatches one person at a time. Today handles the other half: one thing split into several, several done at once, and somebody signing off afterwards.
Plain-Language Walkthrough
One pitch meeting: who splits, who writes, who reviews
A newspaper gets a lead: a brand has been exposed. The editor does not write the story themselves; they hold a pitch meeting first and split it into three angles — the timeline of events, the parties' responses, and the industry background. Three reporters each take an angle and go out to report, none waiting for the others. The copy comes back and an editor reads each piece: the timeline lacks the key dates, so back it goes; the other two pass. With all three in hand, they assemble tomorrow's page.
Those are today's three roles, one for one:
- Planner is the editor: responsible only for splitting a one-sentence request into several subtasks that can run in parallel, doing no work itself.
- Executor is the reporter: responsible only for finishing the one piece in hand, unconcerned with what anybody else is doing.
- Critic is the copy editor: responsible only for judging whether the output passes, bouncing it back with a reason when it does not.
The contrast with yesterday is clear: a Supervisor is a fork where one of three roads is taken; today's graph is a fan-out, then a join, with a back edge in the middle. In D15's four features it has fan-out, join, and back edge simultaneously, the most complex graph in this course so far.
+--) executor(t-1) --+
START - planner --+--) executor(t-2) --+--) critic --) respond - END
+--) executor(t-3) --+ ^ |
+----------+
failed goes back for a redo (at most twice)Where does the three reporters' copy go? Into a workspace state everybody can read and write — the workspace field fixed on D15. The editor writes three to-do items into it, each reporter changes their own item into a written version, the copy editor reads the whole block to judge, and a final node assembles it into a reply. Note the trap hidden in that sentence: three reporters put copy into the same basket at the same time.
Without a framework, how would you write it? Most likely a Promise.all firing all three at once, then splicing the returned array into a shared object. Everything is fine there, because you merge once after Promise.all. But once those three become three nodes in a graph scheduled by the framework, merging is no longer hand-written by you — it is handed to the field's own merge rule. And the rule D15 gave workspace happens to be wrong.
Interview questions
What problem does the Planner-Executor-Critic structure solve, and how is it different from Supervisor routing?Planner-Executor-Critic 这种结构解决了什么问题?它和 Supervisor 路由的区别在哪?
Common in ChinaCommon overseasBasic#multi-agent#orchestration#architecture🔒 Unlock this chapter to see the answer keys.
When several subtasks run in parallel and all write the same shared state, how do you design it so they do not clobber each other?多个子任务并行执行、都要写同一份共享状态时,怎么设计才不会互相覆盖?
Common in ChinaCommon overseasDeep dive#multi-agent#state-management#concurrency🔒 Unlock this chapter to see the answer keys.
Why give each subtask a tool-call budget, and what do you do when it runs out?为什么要给每个子任务设 toolBudget 这样的预算?超了预算之后你会怎么处理?
Common in ChinaCommon overseasIntermediate#cost-control#reliability#agent-design🔒 Unlock this chapter to see the answer keys.
How do you keep a Critic review loop from spinning forever, and what else needs guarding besides a retry cap?Critic 的评审回路怎么防止陷入死循环?除了次数上限还有什么要防的?
Common in ChinaCommon overseasIntermediate#reflection#loop-guard#reliability🔒 Unlock this chapter to see the answer keys.
