Building Recursive Agent Systems
At Cursor, we run thousands of agents to help us train the next version of Composer. We give them research tasks, and if they aren't succeeding or run into issues...
At Cursor, we run thousands of agents to help us train the next version of Composer. We give them research tasks, and if they aren't succeeding or run into issues, they DM us on Slack or page us via PagerDuty.
We've built an org chart of agents that work together. As we've scaled training for Composer, we've wanted to run thousands more experiments.
Lee Robinson(Cursor 开发者教育负责人,前 Vercel VP)分享了 Cursor 内部的递归 Agent 系统架构。该系统用于训练下一代 Composer——Cursor 的 AI 编程模型。核心思路:构建一个"Agent 组织架构图",让数千个 Agent 以层级递归方式协作完成研究任务。
系统架构
To speed things up and parallelize work, we built an always-running agent system (yes, it's a loop). An agent system for research.
层级结构:
- 主 Agent (Main Agent) — 运行在大型远程机器上,拥有本地开发的所有工具,使用磁盘文件作为 "inbox"(任务收件箱),负责任务分发和结果收集
- 子 Agent 集群 (Child Agents) — 主 Agent 通过 SSH 连接到运行数百个子 Agent 的机器,将子 Agent 状态收集到 inbox,使用云端机器集群并行运行实验
- 人机协作 — Agent 遇到问题自动升级:通过 Slack DM 或 PagerDuty 通知人类,人类在关键节点介入决策
Planner + Worker 架构(Cursor 博客补充)
来自 Cursor 官方博客 Scaling Long-Running Autonomous Coding:
- Planners: 持续探索代码库并创建任务,可递归生成子 Planner
- Workers: 专注完成分配的任务,不关心全局
- Judge: 每轮结束判定是否继续
关键发现
- GPT-5.2 比 Opus 4.5 更适合长时间自主工作(Opus 倾向提前停止)
- 不同模型适合不同角色:GPT-5.2 做 Planner 优于 GPT-5.1-Codex
- 去掉复杂性比增加复杂性更有效——最初建的 integrator 角色反而制造瓶颈
- Prompt 比模型和 harness 都重要:"the prompts matter more"
- 最佳结构是"中间地带"——太少会冲突和漂移,太多会脆弱
实验成果
- 从零构建 Web 浏览器:近 1 周运行,100 万+ 行代码,1000+ 文件
- Solid → React 迁移:3 周,+266K/-193K 编辑
- 视频渲染:Rust 重写加速 25 倍,已合并到生产
- Java LSP: 7.4K commits, 550K LoC
- Windows 7 模拟器: 14.6K commits, 1.2M LoC
- Excel: 12K commits, 1.6M LoC
关键洞察
- 递归是核心模式: 主 Agent 管理子 Agent,子 Agent 可再生成子 Agent,形成类似公司组织架构的层级
- 并行化需要正确抽象: 早期尝试扁平自协调(加锁)失败——Agent 风险规避、锁瓶颈、系统脆弱
- 角色分离是关键: Planner 负责思考,Worker 负责执行,Judge 负责评估
- Agent 失败时的升级路径: 不是静默失败,而是主动通知人类(Slack/PagerDuty)
- 简单胜过复杂: 最好的系统往往比预期简单,prompt 工程比架构设计影响更大
- 模型选择需要匹配角色: 不同模型有不同特长,不应用一个通用模型做所有事
来源: Lee Robinson @ X · Cursor Blog