跳到主内容
@wquguru
精选85Cursor 博客(web_list)技巧与观点

Cursor 自研多智能体编排框架,千级 Agent 连续一周自主开发浏览器

Read more →

原文
发到 X
推荐理由

做多智能体编排和长时自主编码的同学必看,Cursor 这次把千级 Agent 协同的踩坑和演进路径讲透了,从锁竞争到角色分工再到连续执行者,直接可借鉴到你的框架设计里。

Blog / research

博客 / 研究

We're excited by the reaction to our research on scaling long-running autonomous coding.

我们对关于扩展长期自主编码的研究所获得的反馈感到兴奋。

This work started as internal research to push the limits of the current models. As part of the research, we created a new agent harness to orchestrate many thousands of agents and observe their behavior. By last month, our system was stable enough to run continuously for one week, making the vast majority of the commits to our research project (a web browser). This browser was not intended to be used externally and we expected the code to have imperfections.

这项工作最初是作为内部研究,旨在推动当前模型的极限。作为研究的一部分,我们创建了一个新的代理框架来编排数千个代理并观察它们的行为。到上个月,我们的系统已经足够稳定,可以连续运行一周,完成了我们研究项目(一个网页浏览器)的大部分提交。这个浏览器并非用于外部使用,我们预期代码会有不完美之处。

However, even with quirks, the fact that thousands of agents could work together to produce work that was almost entirely runnable without human intervention felt like a milestone worth sharing. Since then, we've continued our research, and we wanted to go more in-depth on how the harness was built.

然而,即使存在瑕疵,数千个代理能够协同工作,产出几乎无需人工干预即可运行的成果,这一事实感觉像是一个值得分享的里程碑。自那以后,我们继续进行研究,并希望更深入地探讨框架是如何构建的。

We're also making part of this research available to try for some users.

我们还向部分用户开放了这项研究的一部分以供试用。

#Background

#背景

Our research project started as a personal side project of mine.

我们的研究项目最初是我个人的一个副业项目。

A browser felt like an interesting benchmark. It was complex enough to reveal limitations with frontier models, and there are many different subsystems that needed to work together.

浏览器感觉像是一个有趣的基准。它足够复杂,能揭示前沿模型的局限性,并且有许多不同的子系统需要协同工作。

My initial plan was to support rendering web pages without JavaScript support. I started by prompting Opus 4.5, asking it to write a detailed plan for building a browser engine. I would repeatedly nudge it to "keep going" to see how far it would go on the plan.

我最初的计划是支持无需JavaScript的网页渲染。我首先提示Opus 4.5,要求它编写一个构建浏览器引擎的详细计划。我会反复推动它“继续”,看看它在计划上能走多远。

This failed quickly. The model lost track of what it was doing, frequently stopped to proclaim success despite being far from it, and got stuck on complex implementation details. But it showed signs of deep knowledge and intelligence. It could write good code in small pieces.

这很快就失败了。模型失去了对自己正在做什么的跟踪,经常在远未完成时停下来宣布成功,并卡在复杂的实现细节上。但它显示出深厚的知识和智能的迹象。它能写出小块的好代码。

The core issue was that the browser was too overwhelming of a task and needed to be broken down into subtasks. Next, I had the agent plan out a dependency graph of major work that agents could take up in parallel. Agents were manually spawned for tasks and nudged when they stopped. This increased the throughput, but the results weren't much better. Agents couldn't communicate with each other or provide feedback on the project as a whole. The system needed to be more dynamic.

核心问题是浏览器任务过于庞大,需要分解成子任务。接下来,我让代理规划出一个主要工作的依赖图,以便代理可以并行承担。代理被手动生成任务,并在停止时被推动。这提高了吞吐量,但结果并没有好多少。代理之间无法相互通信,也无法对整个项目提供反馈。系统需要更加动态。

Meanwhile, GPT-5.1 (and later GPT-5.2) began showing better results for their ability to follow instructions precisely. This seemed like a good fit for long-running agents, so we updated our harness to use OpenAI models based on these experiments.

与此同时,GPT-5.1(以及后来的GPT-5.2)开始展现出更好的精确遵循指令的能力。这似乎非常适合长期运行的代理,因此我们根据这些实验更新了框架,使用OpenAI模型。

At this point, the harness could build a simple version of the web browser without JavaScript, but building a complete browser engine with one agent would be prohibitively slow.

此时,测试框架能够构建一个不含JavaScript的简单版网页浏览器,但仅凭一个代理来构建完整的浏览器引擎将极其缓慢。

This started our next round of research. Could we spend 10x more on compute to get 10x more meaningful throughput?

这开启了我们的下一轮研究。我们能否投入10倍的计算资源,以获得10倍的有效产出?

#From single to multi-agent

#从单一代理到多代理

We started a new repository with a simple Rust-based harness.

我们启动了一个新仓库,采用基于Rust的简单测试框架。

Rather than dealing with the complexity of distributed systems, we instead ran the harness on a single large Linux VM (Virtual Machine) with lots of resources. To control the harness, we would SSH into the VM and use a simple terminal interface.

为了避免分布式系统的复杂性,我们改为在单个资源丰富的大型Linux虚拟机(VM)上运行测试框架。通过SSH进入虚拟机,并使用简单的终端界面来控制它。

We spent more time up front on proper observability into the system. We logged all agent messages, system actions, and command outputs, with timestamps so we could analyze and replay sessions. This was not only helpful for us to manually review, but also for piping back into Cursor to sift through large amounts of data and quickly find patterns.

我们在前期投入更多时间,确保系统具备良好的可观测性。我们记录了所有代理消息、系统操作和命令输出,并附上时间戳,以便分析和回放会话。这不仅有助于我们手动审查,也便于将大量数据反馈给Cursor,快速发现模式。

#Self-coordination

#自我协调

Our first multi-agent idea was the most simple: have agents with equal roles use a shared state file to see what others are working on, decide what to work on, and update the file.

我们的第一个多代理想法最为简单:让角色平等的代理使用共享状态文件,查看他人正在处理的任务,决定自己的工作内容,并更新该文件。

We would be the least prescriptive about what to do and instead let the agents figure out how to self-coordinate. This failed quickly.

我们尽量少做规定,让代理自行探索如何自我协调。这一尝试迅速失败。

The coordination file quickly created more problems. Agents held locks for too long, forgot to release them, tried to lock or unlock when it was illegal to, and in general didn't understand the significance of holding a lock on the coordination file. Locking is easy to get wrong and narrowly correct, and more prompting didn't help.

协调文件很快引发了更多问题。代理持有锁的时间过长,忘记释放锁,在不合法的情况下尝试加锁或解锁,并且普遍不理解在协调文件上持有锁的重要性。锁操作容易出错且难以精确,增加提示也无济于事。

Locking also caused too much contention. 20 agents would slow to the throughput of 1-3 with most time spent waiting on locks. We tried giving agents a tool to explicitly wait on another agent's work, but they rarely used it. We also tried a lockless optimistic concurrency control approach, which reduced overhead but didn't eliminate confusion.

锁还导致了过多的竞争。20个代理的吞吐量会降至1-3个代理的水平,大部分时间都花在等待锁上。我们尝试给代理提供工具,让他们明确等待其他代理的工作,但他们很少使用。我们还尝试了无锁的乐观并发控制方法,这减少了开销,但并未消除混乱。

The lack of structure between agents meant no single agent took on big, complex tasks. They avoided contention and conflict, opting for smaller and safer changes versus taking responsibility for the project as a whole.

代理之间缺乏结构意味着没有单个代理承担大型复杂任务。他们避免竞争和冲突,倾向于选择更小、更安全的改动,而不是对整个项目负责。

#Adding structure and roles

#增加结构和角色

Next, we separated roles to gives the agents ownership and accountability:

接下来,我们划分了角色,赋予代理所有权和责任感:

A planner would first lay out the exact approach and deliverables to make progress toward the user's instructions. This would be handed to an executor, who became the sole lead agent responsible for ensuring the plan was achieved completely. The executor could spawn tasks for workers, which provided linear scaling and throughput.

规划者首先会制定出确切的方法和交付物,以朝着用户的指示取得进展。这将交给执行者,执行者成为负责确保计划完全实现的唯一主导代理。执行者可以为工人分配任务,这提供了线性扩展和吞吐量。

For continued movement and accountability, an independent judge ran after the executor finished to determine whether it completed and whether another iteration should run. This resolved many coordination issues. Having a single role dedicated to owning and overseeing execution allowed workers to focus narrowly on their task while the overall system still delivered.

为了持续进展和问责,一个独立的评判者在执行者完成后运行,以确定其是否完成以及是否应运行另一轮迭代。这解决了许多协调问题。让单一角色专门负责拥有和监督执行,使得工人能够专注于自己的任务,而整个系统仍然能够交付成果。

#Observing and hill-climbing

#观察与爬山法

Landing on this design required close observation of the system.

达到这一设计需要对系统进行密切观察。

If there was a major problem, it would tend to occur repeatedly and across many agents and tool calls. For example, we noticed there was too much contention because many agents were running git restore at once. We used Cursor to analyze logs and compare them against our prompts to understand why behavior didn't match expectations.

如果存在重大问题,它往往会在多个代理和工具调用中反复出现。例如,我们注意到由于许多代理同时运行git restore,导致争用过多。我们使用Cursor分析日志,并将其与我们的提示词进行比较,以理解为什么行为与预期不符。

Ultimately, we found this system to be bottlenecked by the slowest worker. It was too rigid.

最终,我们发现这个系统受限于最慢的工人。它过于僵化。

Doing all planning upfront also made it hard for the system to dynamically readjust as new issues were discovered. Some agents would end up going in counterproductive directions, unable to self-correct until the next iteration of the loop.

预先完成所有规划也使系统难以在发现新问题时动态调整。一些代理最终会走向适得其反的方向,直到循环的下一次迭代才能自我纠正。

#Continuous executor

#持续执行者

The next version removed the independent planner.

下一个版本移除了独立的规划者。

The executor could now also plan how to deliver the goal in addition to spawning tasks. Since it was the sole agent, it didn't need to write a plan anywhere, stick to one static unchanging plan, or rigidly wait for all workers.

执行者现在除了分配任务外,还可以规划如何实现目标。由于它是唯一的代理,它不需要在任何地方写下计划,坚持一个静态不变的计划,或僵化地等待所有工人。

#Ensuring freshness

#确保新鲜度

To ensure agents across all roles wouldn't drift over long periods of time, we introduced freshness mechanisms:

为了确保所有角色的代理不会在长时间内偏离,我们引入了新鲜度机制:

  • A scratchpad.md should be frequently rewritten versus being appended to.
  • Individual agents should automatically summarize when reaching context limits.
  • We added self-reflection and alignment reminders to the system prompts.
  • Agents were encouraged to pivot and challenge assumptions at any time.
  • scratchpad.md 应频繁重写,而不是追加内容。
  • 个体代理在达到上下文限制时应自动进行总结。
  • 我们在系统提示中添加了自我反思和一致性提醒。
  • 鼓励代理随时转向并质疑假设。

The system was now highly dynamic and flexible: it could proactively explore code, reconsider decisions, manage workers, interleave tasks, and continuously reflect the latest information. We found agents were reasonably good at following instructions to completion, so the judge was removed to keep the system simple.

系统现在高度动态和灵活:它可以主动探索代码,重新考虑决策,管理工人,交错任务,并持续反映最新信息。我们发现代理在遵循指示完成任务方面相当不错,因此移除了评判者以保持系统简单。

#Pathological behaviors

#病态行为

Despite these improvements, the continuous executor started exhibiting pathological behaviors. It would sleep randomly, stop running agents, do work itself, refuse to plan and spawn more than a few narrowly focused tasks, not properly merge worker changes, and claim premature completion.

尽管有这些改进,连续执行器开始表现出病态行为。它会随机睡眠,停止运行代理,自己动手做事,拒绝规划并生成少量狭窄聚焦的任务,不恰当地合并工作者的更改,并声称过早完成。

We found it was being given too many roles and objectives simultaneously, including: plan, explore, research, spawn tasks, check on workers, review code, perform edits, merge outputs, and judge if the loop is done. In retrospect, it makes sense it was overwhelmed.

我们发现它同时被赋予了过多的角色和目标,包括:规划、探索、研究、生成任务、检查工作者、审查代码、执行编辑、合并输出,以及判断循环是否完成。回想起来,它不堪重负是有道理的。

#The final system design

#最终系统设计

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

另一事件,读法相近