Mingyu's Library主页
深度学习文档 · AI Daily(08-03 补生成)Deep-Dive · AI Daily (backfilled 08-03)

Planner–Executor 分层编排
——Cursor Agent Swarm 深读

Planner–Executor Orchestration
— Inside Cursor's Agent Swarm

「前沿模型只做规划,廉价模型负责执行」——Cursor 2026 年 7 月 20 日的研究长文用一场 SQLite 重写实验给出了迄今最有数字支撑的多智能体工程报告:同等质量,执行成本相差 22 倍。本文拆解它的机制、失效模式与可迁移的设计原则。

"Frontier models plan; cheap models execute." Cursor's July 20, 2026 research post backs this with the most data-rich multi-agent engineering report to date — a SQLite-rebuild experiment where identical quality came at a 22x spread in execution cost. This document unpacks the mechanism, the failure modes, and the transferable design principles.

📅 调研日期:2026-08-03📅 Researched: 2026-08-03 🌐 主来源:Cursor 官方博客(Wilson Lin)+ 媒体解读🌐 Primary source: Cursor blog (Wilson Lin) + press analysis 🀄/🅰️ 中英双语,右上角切换🀄/🅰️ Bilingual — toggle top right

1🔭 开篇速览:30 秒版本🔭 At a Glance: The 30-Second Version

它解决什么痛点:单个 Agent 跑长任务会「跑丢」——要么埋头细节忘了全局,要么盯着全局做不好细节;而把一群 Agent 简单并行起来,又会陷入合并冲突和重复劳动的泥潭(Cursor 旧系统重写 SQLite 时,两小时攒下 7 万+ 次合并冲突,被迫中止)。

The pain it solves: a single agent on a long task drifts — either it buries itself in detail and loses the big picture, or holds the big picture and botches the details. Naively parallelizing a crowd of agents instead drowns in merge conflicts and duplicated work (Cursor's old system racked up 70,000+ merge conflicts in two hours of the SQLite rebuild and had to be paused).

它的答案:把任务组织成一棵任务树,由两种角色分工:Planner(规划者)用最强的模型,只做拆解、设计决策和委派,从不写代码;Worker(执行者)用快而便宜的模型,只执行叶子任务,从不做规划。配上专为高并发自研的版本控制系统和一组「评审透镜」,新蜂群仅凭 835 页官方文档就用 Rust 重写了 SQLite,并最终 100% 通过 sqllogictest 测试套件。

Its answer: organize work as a task tree with two roles: planners on the strongest models do only decomposition, design decisions and delegation — they never touch code; workers on fast, cheap models only execute leaf tasks — they never plan. Add a purpose-built high-concurrency version control system and a set of "review lenses," and the new swarm rebuilt SQLite in Rust from nothing but its 835-page manual, ultimately passing 100% of the sqllogictest suite.

💰 一句话记住结论
💰 The one-line result

四种模型搭配,质量几乎相同,总成本从 $1,339(Opus 4.8 规划 + Composer 2.5 执行)到 $10,565(GPT-5.5 包办一切)不等;仅看执行侧,$411 对 $9,373,相差 22 倍。贵的智力只该花在少数真正需要它的时刻。

Four model mixes, near-identical quality, total costs from $1,339 (Opus 4.8 planning + Composer 2.5 executing) to $10,565 (GPT-5.5 doing everything); on the execution side alone, $411 vs. $9,373 — a 22x spread. Expensive intelligence should be spent only on the few moments that genuinely require it.

2🌳 核心机制:任务树与双角色🌳 Core Mechanism: The Task Tree & Two Roles

大任务的描述天然长成一棵树:根部是目标,递归拆分到基本工作单元。Cursor 蜂群的两种角色就绕着这棵树分工——这不是随意的架构选择,而是对「单 Agent 为什么会漂移」的直接回应。

Descriptions of large tasks naturally take the shape of a tree: a goal at the root, subdividing recursively into basic units of work. The swarm's two roles organize around that tree — not an arbitrary choice, but a direct answer to why single agents drift.

目标(Spec)如:按 835 页文档重写 SQLite Planner · 最强模型拆解 / 设计决策 / 委派,从不写码 子 Planner继续拆,树随问题轮廓生长 子 Planner上下文只装规划,不装细节 Worker · 廉价模型 Worker · 只执行 Worker · 不规划 Worker · 窄上下文 Goal (spec)e.g. rebuild SQLite from an 835-page manual Planner · strongest modelDecompose / decide / delegate — never codes Sub-plannerTree grows to fit the problem Sub-plannerContext holds plans, not detail Worker · cheap model Worker · executes only Worker · never plans Worker · narrow context
图 1 · 任务树与双角色:树的形状随问题轮廓生长,算力与上下文随复杂度按比例伸缩。图据 Cursor 博客描述重绘。
Fig. 1 · The task tree and two roles: the tree's shape grows to fit the problem; compute and context scale with complexity. Redrawn from the Cursor post's description.
为什么分层能治「漂移」:上下文效率
Why layering cures drift: context efficiency
机制单 Agent 走完整棵树,必须同时在上下文里装着祖先节点、当前位置和总目标。Cursor 认为这正是长跑单 Agent 漂移的原因:专注眼前就丢全局,顾着全局就做不好眼前。分层后,Planner 的上下文永远不被底层细节填满,Worker 的上下文全部花在一小块活上
MechanismA single agent walking the whole tree must hold ancestors, current position, and the wider goal in context at once. Cursor argues this is exactly why long-running single agents drift: focus on the work and lose the picture, or hold the picture and do worse work. With layering, a planner's context never fills with low-level detail, and a worker spends all of its context on one narrow piece.
关键判断Cursor 明确说:蜂群的可扩展性「更多来自上下文效率,而非并行本身」——这也是为什么这套分解在中等任务上同样有收益。
Key claimCursor states the swarm's scalability comes "from this context efficiency, more than from parallelism itself" — which is why the decomposition helps even on moderately sized tasks.
类比文章援引经济学家科斯(Ronald Coase)的企业理论:协调成本比工作本身涨得快,所以组织总会沉淀为有边界的分层单元,而不是人人互相直连。
AnalogyThe post invokes economist Ronald Coase's theory of the firm: coordination costs grow faster than the work itself, so organizations settle into tiers of bounded units rather than letting everyone talk to everyone.

同一套设计已被 Cursor 用在多种任务上:从零造浏览器、解数学题、优化 GPU kernel、给开源软件找漏洞、提高自家代码库测试覆盖率、生成数十亿 token 的合成训练数据。

Cursor reports using the same design across diverse tasks: building a browser from scratch, solving math problems, optimizing GPU kernels, finding vulnerabilities in open-source software, raising test coverage on its own codebase, and generating billions of tokens of synthetic training data.

3🛠️ 协调工程:每秒千次提交下的失效与修法🛠️ Coordination Engineering: Failures & Fixes at 1,000 Commits/Second

分层只是骨架,真正的工程量在协调层。Git 这类工具靠粗粒度锁做并发控制,对一名开发者够用,对数百个并发 Agent 完全不够——旧蜂群在 Git 上峰值约每小时 1000 次提交,新系统为此从零自研了版本控制系统(VCS),峰值达每秒约 1000 次提交。所有变更都过 VCS,冲突在这里最先显形,多项协调机制也直接内建其中。

Layering is just the skeleton; the real engineering lives in coordination. Tools like Git use coarse locks for concurrency — fine for one developer, unworkable for hundreds of concurrent agents. The old swarm peaked at ~1,000 commits per hour on Git; the new system ships a version control system built from scratch, peaking at ~1,000 commits per second. Every change passes through it, collisions surface there first, and several coordination mechanisms are implemented directly inside it.

在这种节奏下,Cursor 观察到五种人类团队很少遇到的失效模式,并给出了各自的修法:

At that tempo, Cursor observed five failure modes human teams rarely hit, each with its own fix:

1
裂脑设计(Split-brain)→ 决策上收 Split-brain design → pull decisions up 两个互不知情的 Planner 在代码库不同角落用不同方式实现同一概念。修法是提示词层面的纪律:设计决策由 Planner 自己做、不下放,且保证任何问题不会被两棵子树各自决定一遍。 Two planners, unaware of each other, implement the same concept differently in different corners. Fix: prompt-level discipline — planners make design decisions themselves rather than delegating, ensuring no two subtrees decide the same question.
2
Planner 互怼 → 共享设计文档 + 调解者 Planner contention → shared design docs + a reconciler 两个 Planner 对同一批文件来回改、互相覆盖——本质是「两幅现实图景」,合并工具解决不了分歧。修法:决策写进共享设计文档,依赖该决策的代码带一个编译期校验的引用指回文档;当 Planner 无意间互相矛盾时,由调解 Agent 合并文档,引用把裁决自动传导到下游。 Two planners fight through back-and-forth changes over the same files — two pictures of reality that merge tooling can't fix. Fix: decisions live in shared design docs; dependent code carries a compile-checked reference back to its doc; when planners unknowingly contradict, a reconciler merges the docs and the references propagate the resolution downstream.
3
合并冲突 → 中立第三方 Agent 仲裁 Merge conflicts → a neutral third-party agent Worker 处理冲突很差,实践中要么覆盖对方、要么放弃自己。修法:由一个只求公正高效的中立 Agent 代表各方解决冲突,类似人类团队的 merge queue。 Workers are bad at conflicts — in practice they overwrite the other change or abandon their own. Fix: a neutral agent whose only goal is impartial, efficient resolution intervenes on behalf of all parties, like a merge queue in human teams.
4
巨型文件(Megafiles)→ 标记冻结 + 外部拆分 Megafiles → flag, freeze, decompose 热门文件人人都添几行,没人负责瘦身,最终「堵死一切」。修法:Worker 可标记臃肿文件,标记后冻结新提交,由外部 Agent 把它拆成小模块。旧系统最热的文件被 1,173 个 Agent 碰过、攒下 7,771 次冲突;新系统全库最热文件只有 47 次。 Popular files grow a few lines per agent with nobody responsible for keeping them small, until they choke everything. Fix: workers flag bloated files; commits freeze; an outside agent decomposes them. The old system's hottest file was touched by 1,173 agents and collected 7,771 conflicts; the new system's most contested file saw 47.
5
僵化(Ossification)→ 许可「有意破坏」 Ossification → license intentional breakage Agent 从「与人协作」的习惯里学会了不碰核心代码,即使核心确实该改。修法:允许 Agent 在职责范围外做一个聚焦补丁并留言说明理由;编译器让所有依赖旧设计的代码构建失败,每个撞上错误的 Agent 读到留言后自行更新自己那块。 From working alongside humans, agents learned never to touch core code — even when it needs to change. Fix: license intentional breakage. An agent may make a focused out-of-scope patch with an explanatory comment; the compiler fails everything depending on the old design, and each agent that hits an error reads the reasoning and updates its own piece.

评审透镜与 Field Guide

Review lenses & the Field Guide

长时程 + 多智能体意味着错误会累积,蜂群需要在小错变成地基之前自我纠偏。Cursor 试验了多种「评审透镜」:有的评审 Agent 看 Worker 全程记录,有的只看产出,有的只看代码库,还让不同模型、不同「性格」的评审并存。结论:没有单一透镜能抓住一切,但彼此不相关的透镜可以叠加——就像自动驾驶靠多个不完美组件叠出超人可靠性。评审算力回报很高,因为评审远比它审计的工作便宜。

Long-running plus multi-agent means errors accumulate; the swarm must self-correct before small mistakes become foundational. Cursor tried many "review lenses": reviewers seeing the worker's full transcript, only its output, or nothing but the codebase — across different models and personalities. Conclusion: no single lens catches everything, but decorrelated lenses stack — the way self-driving systems reach above-human reliability without any single perfect component. Review compute is high-return, since review is much cheaper than the work it audits.

另一项实验借鉴了蚁群的共识主动性(stigmergy)——通过改造环境来协调彼此:一个完全由 Agent 拥有的「Field Guide」文件夹,其 index.md 自动注入每个新启动的 Agent,由 Agent 自己决定什么值得写进去(唯一约束是行数预算)。逻辑很朴素:模型权重是冻结的,恰恰是「意外遭遇」值得记录,好让下一个 Agent 的轨迹更短。

Another experiment borrows stigmergy from ant colonies — coordinating by shaping the environment: a "Field Guide" folder owned entirely by the agents, whose index.md is auto-injected into every agent at start; the agents curate it themselves under a line budget. The logic is plain: model weights are frozen, so it's precisely the surprise encounters worth capturing so the next agent's trajectory is shorter.

4🧪 SQLite 实验:设置与结果🧪 The SQLite Experiment: Setup & Results

考题:仅凭 835 页 SQLite 官方手册,用 Rust 从零实现整个数据库——源码、测试套件、SQLite 程序、互联网,一律不给。评分用 SQLite 项目自己的 sqllogictest(数百万条已知正确答案的查询),蜂群不知道这套测试的存在;每轮结束后 Cursor 人工审查代码与过程,排查作弊与偷工。

The exam: implement the entire database in Rust from nothing but SQLite's 835-page manual — no source, no test suites, no SQLite binary, no internet. Grading used the SQLite project's own sqllogictest (millions of queries with known answers); the swarm was never told the suite existed, and Cursor manually reviewed code and runs afterward for cheating and shortcuts.

100%
新蜂群四种模型组合最终全部通过全套测试;四小时截点成绩 73–85%(旧蜂群 11–77%)
All four new-swarm mixes ultimately passed the full suite; 73–85% at the 4-hour cutoff (old swarm: 11–77%)
70,000+ → <1,000
旧 vs 新蜂群(Grok 4.5)累计合并冲突数;旧系统冲突加速失控被暂停
Old vs. new swarm (Grok 4.5) cumulative merge conflicts; the old run accelerated out of control and was paused
64,305 → 9,908
通过全套测试所需引擎代码行数(Fable 5 组合,旧 vs 新)——协调好了,代码也更精炼
Engine LOC needed to pass the full suite (Fable 5 mix, old vs. new) — better coordination, leaner code

结构性指标同样说明问题:旧系统(Grok 4.5)前两小时狂产 68,000 次提交——约为新系统节奏的 70 倍,但多数是空转(冲突、争抢、翻烧饼);包结构上,旧系统蔓生出 54 个 Rust crate、其中 3 个都是 SQL 包(裂脑的直接证据),新系统早早定型 9 个 crate 后再未增加。

Structural metrics tell the same story: the old system (Grok 4.5) churned out 68,000 commits in its first two hours — about 70x the new system's pace, mostly busywork (thrash, contention, churn). In package structure, the old run sprawled to 54 Rust crates including three separate SQL packages (split-brain in the flesh); the new run settled on nine crates early and never added another.

⚠️ 读数须知
⚠️ Reading the numbers

这是厂商自述的内部实验:评分虽用外部测试套件,但实验设计、人工审查和数字均出自 Cursor 一方;曲线形状受 Agent 自选策略影响(「趋势比某时刻的确切分数更重要」是 Cursor 自己的提醒)。Opus 4.8 单跑产出的代码库已公开(github.com/cursor/minisqlite),可自行检验。

This is a vendor-reported internal experiment: the grader is an external suite, but design, review, and numbers all come from Cursor. Curve shapes reflect agents' self-chosen strategies ("trends matter more than exact scores at exact moments" is Cursor's own caveat). The solo Opus 4.8 codebase is public at github.com/cursor/minisqlite for independent inspection.

5📊 模型经济学:钱花在哪、省在哪📊 Model Economics: Where the Money Goes

四种配置质量趋同,成本天差地别。token 的分布很一致——Worker 至少吞掉 69% 的 token(多数配置超 90%);但钱的分布不同,因为 Planner 的 token 更贵:在 Opus 4.8 + Composer 2.5 组合里,Opus 产出的 token 占比很小,却占了约三分之二的花费。

Four configurations, converging quality, wildly different costs. Token structure was consistent — workers carried at least 69% of tokens (over 90% in most runs); but dollars split differently because planner tokens cost more: in the Opus 4.8 + Composer 2.5 mix, the planner produced a small fraction of tokens yet roughly two-thirds of the cost.

重写 SQLite 的总成本(质量相近,数据:Cursor) GPT-5.5 包办规划+执行$10,565 Grok 4.5 包办规划+执行约 1/4 – 1/2(未公布精确值) Fable 5 规划 + Composer 2.5 执行高于 Opus 组合(worker 端 token 更多) Opus 4.8 规划 + Composer 2.5 执行$1,339 仅执行侧:GPT-5.5 workers $9,373 vs Composer 2.5 workers $411 —— 相差 22 倍 注:条长按已公布数字示意;Grok / Fable 组合官方未给出精确总额,仅给相对描述。 Total cost to rebuild SQLite (similar quality; data: Cursor) GPT-5.5 plans + executes$10,565 Grok 4.5 plans + executes~1/4–1/2 (exact figure not published) Fable 5 plans + Composer 2.5 executesabove the Opus mix (more worker tokens) Opus 4.8 plans + Composer 2.5 executes$1,339 Execution side only: GPT-5.5 workers $9,373 vs. Composer 2.5 workers $411 — a 22x spread Note: bar lengths are indicative, anchored to published figures; Grok/Fable totals were described only relatively.
图 2 · 同等质量下的成本谱系。Cursor 的解释:大任务中真正需要前沿智力的时刻很少(最初的拆解、设计决策、关键取舍);前沿 Planner 把歧义坍缩成明确指令后,便宜模型照做即可。
Fig. 2 · The cost spectrum at equal quality. Cursor's explanation: few moments in a large task genuinely require frontier intelligence (the original decomposition, design decisions, key trade-offs); once a frontier planner collapses ambiguity into explicit instructions, cheap models simply follow.
🔍 一个反直觉细节:更强的 Planner ≠ 更省的整体
🔍 A counterintuitive detail: a stronger planner ≠ a cheaper run

Fable 5 做 Planner 时,规划账单反而比 Opus 4.8 略低(单价约两倍,但规划 token 少得多)——然而它带的 Worker 消耗了数倍 token,整体反而明显更贵。规划的质量不只体现在规划本身的开销,更体现在它给执行端省了多少弯路;这两者未必同向。

With Fable 5 as planner, the planning bill came out slightly below Opus 4.8's (about twice the per-token price, far fewer planning tokens) — yet its workers burned several times as many tokens, making the run substantially more expensive overall. Planning quality shows up not in the planner's own bill but in how many detours it saves the executors — and the two don't necessarily move together.

6🧭 迁移要点与局限🧭 Transfer Notes & Limits

给自己搭 Agent 系统的读者,可直接带走的设计原则:

If you're building your own agent systems, the portable principles:

角色即模型档位Roles are model tiers把「用哪个模型」从全局配置变成按角色配置:规划/评审用贵的,执行用便宜的。The Decoder 的解读估计,凡是存在可验证性的场景,当下就有 6–8 倍的成本空间。Turn "which model" from a global setting into a per-role setting: expensive for planning/review, cheap for execution. The Decoder's read: a 6–8x saving is available today wherever verification exists.
验证器前置Verification first整个便宜执行的前提是「结果可被廉价判对错」(编译器、测试套件)。没有验证器的领域,分层省钱的逻辑要打折——先补验证,再谈蜂群。Cheap execution presupposes cheap verification (compilers, test suites). In domains without verifiers, the economics discount heavily — build verification before building swarms.
协调是一等公民Coordination is first-classCursor 为协调专门造了 VCS、调解 Agent、文件拆分 Agent、评审栈——协调机制的工程量不小于 Agent 本身。想省掉这层的多智能体系统,大概率复演「7 万次合并冲突」。Cursor built a VCS, reconciler agents, file-decomposition agents, and a review stack just for coordination — engineering rivaling the agents themselves. Skip this layer and you'll likely re-enact the 70,000 merge conflicts.
Spec 成为工作单元The spec becomes the unit of workCursor 的收尾判断:自动补全的单位是行,Agent 的单位是文件/功能,蜂群的单位是 spec;蜂群像一台「意图编译器」,而稀缺的将是「对意图的正确描述」。Cursor's closing claim: autocomplete worked in lines, agents in files/features, swarms in specs; the swarm resembles a compiler for intent — and what's scarce is the right description of intent.
⚠️ 三条局限,别外推过头
⚠️ Three limits — don't over-extrapolate

单源厂商报告:数字未经独立复现,且 Cursor 自家销售廉价模型(Composer)与该结论存在利益一致性。② 任务选择偏向:SQLite 重写是「规格明确 + 验证完美 + 高度可并行」的理想蜂群任务;Google–MIT 研究提示,强耦合任务上多智能体的协调开销可能吃掉收益。③ 模型敏感性真实存在:Cursor 自己就因 GPT-5.6 Sol 对措辞过敏、出现「失控螺旋」而弃用之——换模型不是免费的。

Single-source vendor report: figures aren't independently reproduced, and Cursor sells a cheap model (Composer) aligned with the conclusion. ② Task-selection bias: the SQLite rebuild is an ideal swarm task — precise spec, perfect verifier, highly parallel; the Google–MIT study warns coordination overhead can erase gains on tightly coupled tasks. ③ Model sensitivity is real: Cursor itself dropped GPT-5.6 Sol after "runaway spirals" from its sensitivity to emphatic wording — swapping models isn't free.

7📚 学习资源清单📚 Learning Resources

解读与对照AnalysisThe Decoder 解读 · 关联主题:本系列 07-09《多智能体编排》、07-19《多模型路由》、07-28《Agent 可观测性》The Decoder's analysis · Related in this series: Multi-Agent Orchestration (07-09), Model Routing (07-19), Agent Observability (07-28)

一句话带走

The One-Line Takeaway

蜂群的可扩展性来自上下文效率而非并行本身;成本优势来自把前沿智力限定在拆解与决策的少数时刻;而这一切能立住的前提,是验证器和一整层不输于 Agent 本身的协调工程。

Swarm scalability comes from context efficiency, not parallelism itself; the cost advantage comes from confining frontier intelligence to the few moments of decomposition and decision; and both stand only on verifiers plus a coordination layer engineered as seriously as the agents themselves.