OctSum
00:00 / 17:31

AI Engineer · 17:31

All right. Um, so again, I'm my name is Potato. Uh, I work on Grokbot at SpaceX SI. And can I just get a quick show of hands? How many of you have ever looked at code that somebody else wrote and you thought, that's all slop? Well, I have two, but today I'm going to convince you that you can turn that slop into gold.

好的。 嗯,再介绍一下,我叫 Potato。 呃,我在 SpaceX SI 负责 Grokbot。 能不能请大家快速举一下手? 你们有多少人看过别人写的代码,心想:这全是垃圾? 嗯,我看到有两个人举手,不过今天我要说服你们,相信你们能把这些垃圾变成黄金。

Uh, and so I did something crazy last month and I shipped 3,000 employee requests to production. Now before agents, we never really cared about volume, uh, except for the outliers. And at my previous company, we called these people coding machines. People like Brett Taylor who famously rewrote all of Google Maps, uh, in a weekend. Just an insanely productive engineer. Uh, and well with agents, anyone can now be a coding machine. And my thesis is that the job of a software engineer, the meta of being a software engineer, is figuring out how to maintain or even improve the quality of your code while massively increasing your productivity. To get there, some people like to call this a software factory, but I like to keep it simple and I think of it as all about trust. Not blind trust, but investing in your agent's environment so you can trust that your agents are going to do the right thing. Now, it takes quite a lot of effort to get there. Um, and it took me six months to get to a point where I could ship thousands of pull requests, a lot of them in my sleep. but it's certainly possible, and it will take you much less time than i did. so let's start by talking about how we move from a low trust environment to a high trust one. so this inverse pyramid is how i think about where to spend time on your agent's environment. the first two layers are deterministic, so using your code itself. so things like good api design, architecture, refactoring, or using lint rules, type systems, compilers, or different kinds of testing. and you can use both of these layers together to constrain what agents can do and force them to do the right thing by default. Verification, both runtime and formal, are great tools to later on to find bugs and check properties and the invariants in your system that you want to hold true, and also help you check whether or not the agent understood your goals and your intent. And then finally you want to layer with a little bit of pros. So things like rules, skills, agents. md, things that require judgment. But let's start with your codebase. Agents generate their outputs based on their inputs. And so the the quality of the input really matters. And it just so happens that your codebase is one of the largest inputs. so whenever you're correcting your agent, think about how you can make that a deterministic check instead of adding another line to your rules or your agents. md, because it's far more reproducible when it's in code and it lets you trust it more.

呃,上个月我做了件疯狂的事:把员工提出的 3,000 个请求发布到了生产环境。 在智能体出现之前,我们其实从来不太在乎数量,呃,除了那些特别突出的例外。 在我上一家公司,我们把这类人称为编程机器。 比如 Brett Taylor,他曾以一个周末重写了整个 Google 地图而闻名。 简直是生产力高得惊人的工程师。 呃,而有了智能体,现在任何人都能成为编程机器。 我的观点是,软件工程师的工作,也就是成为软件工程师的核心要义,是想办法在大幅提高生产力的同时,维持甚至提升代码质量。 要做到这一点,有些人喜欢把它称作软件工厂,但我喜欢化繁为简,我认为关键在于信任。 不是盲目信任,而是为智能体的运行环境投入精力,这样你才能相信它们会做正确的事。 要做到这一点,需要付出相当多的努力。 嗯,我花了六个月才做到能发布数千个拉取请求,其中很多还是在我睡觉时发布的。 但这当然是可行的,而且你们不需要像我花那么长时间。 那么,我们先来聊聊如何从低信任的环境转向高信任的环境。 这个倒金字塔体现了我对如何分配时间来打造智能体运行环境的看法。 前两层是确定性的,因此可以直接利用你的代码本身。 比如良好的 API 设计、架构、重构,或使用 lint 规则、类型系统、编译器以及不同类型的测试。 你可以同时运用这两层,限制智能体能做什么,并让它们默认就按正确的方式行事。 运行时验证和形式化验证都是很好的工具,可以在之后用来查找错误、检查系统中的属性,以及确认你希望成立的不变量;它们也有助于判断智能体是否理解了你的目标和意图。 最后,你还想再加上一点提示词。 比如规则、技能、智能体。 md 这类需要判断力的东西。 但我们先从你的代码库说起。 智能体会根据输入生成输出。 所以,输入的质量确实很重要。 而你的代码库恰好是最大的输入之一。 所以,每当你在纠正智能体时,想想怎样把它变成确定性的检查,而不是再往规则或智能体的提示词文件里加一行。 因为把它写进代码后,可复现性要高得多,也更值得信赖。

and the analogy that i like to use is that your code base is kind of like a garden. you know, code used to arrive a few pull requests at a time. and i remember going into work in 2024 and reviewing the three pull requests that my colleagues wrote. and today, that number is more like 300. so, you know, every engineer is now a team of hundreds or even thousands of agents. and code is arriving so rapidly that it almost feels like a continuous stream. And it almost feels organic, like a living thing. and in this analogy, your code base, the constraints that you impose, the guardrails that you put up, are the concrete foundations that the new code that your agents write grow around, just like the building in this picture. and so in many ways, the job of being a software engineer is kind of becoming like gardening. because code is the biggest input for agents, it means that any workarounds, anti-patterns, deprecated code, tech debt, it's now likely to be just copied by the next agent since it looks like the established pattern in your code base. and it's like you have some weeds or pests growing in your garden and then they spread everywhere before you know it. So you want to make your code base as pristine as possible so that agents are always copying the good stuff. All right, let's look at some real examples.

我喜欢用这样的比喻:你的代码库就像一座花园。 你知道,以前代码每次只是随着几个拉取请求陆续提交进来。 我记得 2024 年去上班时,还会审查同事写的三个拉取请求。 而如今,这个数字更接近 300。 所以现在,每位工程师都相当于带领着一支由数百乃至数千个智能体组成的团队。 代码涌入的速度如此之快,几乎像一条源源不断的溪流。 它几乎给人一种有机的感觉,就像一个活生生的东西。 在这个类比中,你的代码库、你施加的约束以及你设置的护栏,就是新代码生长其上的坚实基础——就像这张图里的建筑一样。 所以在很多方面,软件工程师的工作正变得有点像园艺。 因为代码是智能体最主要的输入,这意味着任何变通方案、反模式、弃用代码和技术债务,都很可能被下一个智能体照搬,因为它们看起来像是你代码库里既有的模式。 这就像花园里长出了杂草或害虫,等你反应过来,它们已经蔓延得到处都是。 所以你要让代码库尽可能整洁,这样智能体复制的就总是优质内容。 好,我们来看看一些真实案例。

So Dune is a client framework that we created for GrokBot to implement this idea for organic architecture. It's not really that interesting technically. Uh, you can kind of think of Dune as, um, kind of like Next. js for Electron apps. But the interesting part of Dune is that it has a lot of constraints and lint rules that we've encoded, uh, a lot of the lessons that we've learned building desktop applications. And one such lesson is that anything that requires nuance to use well often leads to slop. Uh, you know, your classic example is, uh, you know, useEffect in React, right? It has its use cases, uh, but it's often misused. You know, some people joke that you need a PhD to use useEffect. and in other words, it really requires a lot of nuance to use well. and agents are not good at using it. so our solution has been to just ban it in product code. and it's really only allowed in some places inside of dune apis. and effectively, this problem has now been categorically eliminated. and we never need to catch that during code review again. Another interesting pattern that we use is context through directory structure. So one anti-pattern that we saw with Cursor, which is an Electron app, is that agents would often import main thread code into the render thread, which would cause long tasks and jank. so in Grokbot and in dune apps, we've made this very, very conventional. we have these two top-level directories, literally called electron renderer and electron main. and imports between them are forbidden or banned by our dependency graph analyzer and some lint rules. and again, these are simple lint rules to set up, but it means one less thing that we need to review and think about during code review.

Dune 是我们为 GrokBot 创建的客户端框架,用来实现这种有机架构的理念。 从技术角度来说,它其实没什么特别有趣的。 嗯,你可以把 Dune 大致理解成类似 Next。 js,不过是用于 Electron 应用的。 但 Dune 有意思的地方在于,它包含了许多约束和 lint 规则,我们将构建桌面应用时吸取的许多经验都编码进了其中。 其中一条经验是,任何需要细致把握才能用好的东西,往往都会导致代码质量低劣。 嗯,你知道,最典型的例子就是 React 里的 useEffect,对吧? 它确实有适用场景,但经常被误用。 你知道,有些人开玩笑说,得有博士学位才能用好 useEffect。 换句话说,要用好它确实需要非常细致的理解。 而智能体并不擅长使用它。 所以我们的解决办法就是直接禁止在产品代码中使用它。 实际上,它只允许在 Dune API 内部的某些地方使用。 这样一来,这个问题就彻底消除了。 这样我们在代码审查时就再也不用捕捉到这个问题了。 我们采用的另一个有趣模式,是通过目录结构传递上下文。 我们在 Cursor(一款 Electron 应用)中看到的一个反模式是,智能体经常把主线程代码导入渲染线程,导致长任务和卡顿。 所以在 Grokbot 和 Dune 应用中,我们把这件事做得非常、非常规范。 我们有两个顶层目录,名字就叫 electron renderer 和 electron main。 依赖关系图分析器和一些 lint 规则会禁止这两个目录之间互相导入。 而且,这些 lint 规则设置起来很简单,但这样一来,我们在代码审查时就少了一件需要检查和考虑的事。

and then one more surprising thing that i've seen is agents using markdown. so things like documentation, code comments, rules or skills. and they use this as a place to write down their justifications for not doing the right thing. or, i don't know if you've ever seen this, but they'll over-rotate on some small correction that you made, and they treat it like a hard rule that can never be broken ever again. and here's another example from cursor. so agents really loved using imperative timers, so things like set timeout, request animation frame, request idle callback. and they were using these as quick fixes because they were really patching over an architecture clash between vs code's imperative style and react's declarative style. So our choice of architecture actually made both the client and the agent performance much worse. And if you've ever done any performance work in JavaScript, you'll know that when you have tons of timers being rapidly created and destroyed, causes a lot of uh major garbage collection, which causes a lot of lag and jank. But the worst part is that agents wrote a lot of code comments, like you can see in red here, explaining why this quick fix was justified. and before you know it, we had timers spreading everywhere and the performance of the app really suffered. now in grokbot, we learned our lesson there and we decided to just ban 99% of comments because they go stale easily. humans just really don't bother reading the comments a lot anyway. and again, it gives an agent an escape hatch to justify not doing the right thing. because it's hard. and the worst part about comments, though, is that they're not enforceable. so what seems well-intentioned, you know, like i'm going to tell the next agent not to do something, never ends up actually being anything that you can trust. so in grokbot and in dune, we now have lint rules that give good and very helpful error messages telling the agent to fix the root cause. the real problem rather than just patch around it. and so our general principle is that every time we correct our agents, it turns into one of these deterministic checks, or we think about how to categorically eliminate that problem in the code through better api design, through better architecture. and if you do this enough times, you'll find that you have just less things to look out for in code review. And at some point you realize there's nothing left to review, and you can just let agents merge most of their own pull requests.

我还见过另一件更让人意外的事:智能体会使用 Markdown。 比如文档、代码注释、规则或技能。 它们会把这些当作记录自己为何不按正确方式做事的理由的地方。 或者,不知道你有没有见过这种情况:你只做了一点小小的纠正,它们却反应过度,把这当成一条永远不能违反的硬性规则。 这里还有一个来自 Cursor 的例子。 智能体特别喜欢用命令式计时器,比如 set timeout、request animation frame 和 request idle callback。 它们把这些当作快速修复手段,因为实际上是在弥补 VS Code 的命令式风格与 React 的声明式风格之间的架构冲突。 所以,我们的架构选择实际上让客户端和智能体的性能都变得更差。 如果你做过 JavaScript 性能优化,就会知道,大量计时器被快速创建和销毁时,会引发大量的垃圾回收,进而造成严重的延迟和卡顿。 但最糟糕的是,智能体写了很多代码注释,就像这里用红色标出的那样,解释为什么这种快速修复是合理的。 没过多久,计时器就到处都是,应用的性能也因此大受影响。 现在,在 Grokbot 中,我们吸取了教训,决定直接禁止 99% 的注释,因为它们很容易过时。 反正人们通常也不太愿意读注释。 而且,这又给了智能体一个借口,让它可以为不做正确的事开脱。 因为这很难。 不过,评论最糟糕的一点是,它们无法强制执行。 所以,看起来出于好意的做法——比如“我要告诉下一个智能体别做某件事”——最终都无法真正成为值得信赖的东西。 因此,在 Grokbot 和 Dune 中,我们现在有一些 lint 规则,它们会给出清晰且非常有帮助的错误信息,告诉智能体去修复根本原因。 也就是实际的问题,而不只是绕着它打补丁。 所以,我们的一般原则是:每次纠正智能体时,都要把这次纠正转化成这类确定性检查;或者思考如何通过更好的 API 设计和架构,从根本上杜绝代码中的这类问题。 这样做的次数足够多之后,你会发现代码审查中需要留意的事情变少了。 到某个时候,你会发现已经没什么需要审查的了,于是可以直接让智能体合并它们自己的大多数拉取请求。

All right, uh, moving on. Verification is also a really big part of how we make our agents more autonomous and also increase our confidence and trust in their work. And our code review process has now really shrunk into looking at verification artifacts instead. So things like videos, screenshots, diagrams, formal verification. Um, and the most basic example of this is runtime verification, uh, which is just a fancy way of saying giving your agent a way to run the code for itself and use debugging tools that, you know, human developers use as well, like the Chrome DevTools protocol. Um, in our runtime verification skills, we have this thing that we call a feature map. and that's basically kind of like a site map of all of the features that are available in your application from the user's point of view. and so with this, agents don't need to guess when you say, you know, the thingy in the left sidebar. it gives you some shared vocabulary. And we also make use of custom CLIs inside these skills so that agents can reuse the CLI and the driver every time, which cuts down on token usage and is also testable. and then recently, we've also started looking at formal verification. so we now use tla plus to do some model checking of major user flows, such as notifications across multiple devices and platforms. we use Lean as well for proving certain algorithms. for example, we have our own, we wrote our own custom virtualization library, and we use lean there to check that we don't have, you know, flickering or jittering problems. and we're still experimenting with this approach. overall, it seems very promising. we've already found quite a few bugs with formal verification. but it's certainly not a silver bullet, and we're treating it as another tool, another layer in our agent's environment. and then this is a very fast video, but another thing that we just started looking at is property-based testing as well for uis. so we use this library called bombadil, and this has also caught a few ui bugs for us already.

好,呃,我们继续。 验证也是让智能体更加自主、同时增强我们对它们工作的信心和信任的重要组成部分。 如今,我们的代码审查流程实际上已经大幅缩减,转而查看验证产物。 比如视频、截图、图表和形式化验证。 嗯,最基础的例子是运行时验证。呃,这只是种听起来很高级的说法,意思是给智能体一种方式,让它自己运行代码,并使用人类开发者也会用的调试工具,比如 Chrome DevTools 协议。 嗯,在我们的运行时验证技能中,有个东西我们称作功能地图。 它基本上就像一张站点地图,从用户的角度展示应用中所有可用的功能。 有了它,当你说“左侧边栏里的那个东西”时,智能体就不必瞎猜了。 它能提供一套共同的词汇。 我们还会在这些技能中使用自定义 CLI,这样智能体每次都能复用 CLI 和驱动程序,从而减少令牌用量,而且还可以进行测试。 最近,我们也开始研究形式化验证了。 因此,我们现在使用 TLA+ 对主要用户流程进行一些模型检查,例如通知在多个设备和平台上的表现。 我们也使用 Lean 来证明某些算法。 例如,我们有自己的虚拟化库,是我们自行编写的定制版本;我们用 Lean 检查它,确保不会出现闪烁或抖动问题。 我们仍在试验这种方法。 总体而言,它看起来很有前景。 我们已经通过形式化验证发现了不少 bug。 但它当然不是包治百病的灵丹妙药,我们把它当作另一种工具,作为智能体环境中的又一层。 接下来这段视频很快带过,不过我们最近开始关注的另一件事,是对 UI 进行基于属性的测试。 我们使用一个叫 Bombadil 的库,它也已经帮我们发现了几个 UI bug。

okay, so zooming out, i saw this tweet from cindy, and six months ago, she said that she was talking about not being able to trust her agents because of subtle bugs that were getting merged. and really what was missing for her in being able to trust her agents was the verification process. and now, six months later, she says that 70% of her daily tokens go into verification. And I'd say that that tracks with what I see as well, that most of my token usage goes to verification. and if you really look closely at our process, none of these things here are new or novel techniques that we've never had before. These are just good software engineering tools, but ones that might have been prohibitively expensive to use before as they were hard to understand or write or maintain. But agents drastically cut this cost down. And really we're entering a golden age of software testing and verification because agents let us test everything to a much greater degree than used to be economical. and then formal verification can also help you better reason about how your product should work and whether your agents really understand your intent and goals. i made this new skill called state chart in my plugin pstack, potato stack, which helps you visualize state machines from the user's point of view. and i find this much easier to review alongside the videos and screenshots that we provide. and so that's been great. sorry for the flashbang.

好,拉远来看,我看到 Cindy 发过一条推文。六个月前,她说自己谈到过无法信任智能体,因为一些微妙的 bug 被合并进了代码。 而她之所以无法信任智能体,真正缺少的就是验证流程。 而现在,六个月过去了,她说自己每天 70% 的 token 都花在验证上。 我想这也符合我的观察:我使用的大部分 token 都花在了验证上。 仔细看看我们的流程就会发现,这里没有任何一项是全新或前所未有的技术。 这些只是优秀的软件工程工具,只不过以前可能因为难以理解、编写或维护,使用成本高得让人望而却步。 但智能体大幅降低了这些成本。 我们确实正在进入软件测试与验证的黄金时代,因为智能体让我们能够以远超以往经济可行程度的规模测试一切。 而且,形式化验证还能帮助你更好地推理产品应该如何工作,以及智能体是否真正理解了你的意图和目标。 我在自己的插件 PStack(Potato Stack)里创建了一项名为 State Chart 的新技能,它能从用户的视角帮助你直观呈现状态机。 我发现,配合我们提供的视频和截图来审查时,这样做容易得多。 所以这一直很不错。 抱歉,刚才闪到你了。

okay, now let's look at what the promised land looks like. what do you get in return for all of this investment? so on the Grokbot team, our velocity is taking off and rapidly increasing. and last month, our team shipped a ridiculous 11,000 pull requests to production, which is a wild number. and our pace of releasing the client has also increased, and we cut a new stable version about once a day. and then the core team is also shipping much more, and we also have a lot more casual or drive-by contributors. who don't always have a lot of context, but they're also contributing. and in october, we had about 227 people who contributed at least one pull request. so despite this velocity accelerating, you might be thinking to yourself, like, isn't this going to be chaos? you know, isn't this going to be a bunch of slop? but actually, the number of prs that get reverted has actually gotten lower on a relative basis and is steady at about half a percent. but i think the really interesting thing about this shipping pace and this volume of pull requests is that the performance of Grokbot has stayed not just stable, but has improved on multiple dimensions compared to when we launched. so startup, typing, opening new chats, switching chats, all of this has gotten faster. And keep in mind, Grokbot is still an Electron app for now. So there is a ceiling, right? But it's already much faster than many other agent UIs out there. And for an Electron app with this high velocity and this many people contributing, I'd say that's pretty good.

好了,现在来看看我们所说的应许之地是什么样子。 投入这么多之后,你能得到什么回报? 在 Grokbot 团队,我们的开发速度正在起飞,而且还在迅速提升。 上个月,我们的团队竟然向生产环境提交了 11,000 个拉取请求,这个数字实在惊人。 客户端的发布节奏也加快了,我们大约每天都会推出一个新的稳定版本。 核心团队的交付量也大幅增加,而且参与贡献的临时贡献者或顺手帮忙的贡献者也多了很多。 他们不一定很了解项目背景,但也在做出贡献。 十月份,至少提交过一个拉取请求的贡献者大约有 227 人。 所以,尽管开发速度在不断加快,你可能会想:这不会变成一团乱吧? 你知道,这不会变成一堆粗制滥造的东西吧? 但实际上,被撤回的拉取请求所占比例反而降低了,目前稳定在约百分之零点五。 不过,我认为这种交付速度和拉取请求数量最有意思的一点是:与刚发布时相比,Grokbot 的性能不仅保持稳定,还在多个方面有所提升。 所以,启动、输入、开启新聊天、切换聊天,这些操作全都变快了。 请记住,Grokbot 目前仍然是一个 Electron 应用。 所以它总有性能上限,对吧? 但它已经比许多其他智能体界面快得多了。 考虑到这是一个开发速度如此之快、参与贡献者如此之多的 Electron 应用,我觉得它已经相当不错了。

So before you jump into building out a software factory and you know automating everything that you can, whenever you correct your agent, try and do it by improving your code base first. You know start with a lint rule to prevent new occurrences of anti-patterns and then clean up those uh old patterns as well. And then make sure that your verification story is really strong. a lot of this work is a prerequisite to automation anyway. and if your inner coding loop produces slop, then automating that loop just produces more slop. and you need to throw more and more and more tokens at the problem, which we all know is very expensive. And once you've made these investments into, you know, code into your code base, static analysis, runtime informal verification, you'll start to find that many things become possible with these foundations and that you can really easily build your own factory on top of these foundations. and when you're ready, grokbot is a great way to build that outer loop. we have tons of connectors, routines that can kick off cursor, cloud agents, and projects, which let you orchestrate thousands of, hundreds or even thousands of agents. and as a quick example, you know, whenever we cut a new release now, grokbot will automatically spin up a new cursor project for us that will fuzz the entire application, the entire build. and it will find bugs by running the app and using it like a real user. and then it's going to open fixed prs for each of those bugs that it finds, and it's going to auto-merge it, as crazy as that sounds. and that's because our code base is good enough that pull requests tend to just be good by default. and most product code that we land no longer really requires deep human review. So, when you have solid foundations and good organic architecture, you can turn slop into gold and you can ship with high quality, high velocity without compromising on quality. My name is potato, also known as lauren. Thanks to you again for listening to my talk.

所以,在你着手搭建软件工厂、试图自动化所有能自动化的事情之前,每当你纠正智能体时,尽量先通过改进代码库来实现。 你知道,先从制定一条 lint 规则开始,防止反模式再次出现,然后也清理掉那些旧模式。 然后确保你的验证机制足够可靠。 反正,这些工作中的很多本来就是实现自动化的前提。 如果你的日常编码流程会产出垃圾代码,那么把这个流程自动化只会产出更多垃圾代码。 而且你就得不断往这个问题上投入越来越多的 token,我们都知道这非常昂贵。 一旦你在代码库、静态分析和运行时非正式验证上进行了这些投入,你就会发现,基于这些基础,许多事情都变得可行,而且你可以很轻松地在这些基础之上打造自己的工厂。 等你准备好了,grokbot 是构建外层循环的好方法。 我们有大量连接器和例程,可以启动 cursor、云端代理和项目,让你协调数百乃至数千个代理。 举个简单的例子,现在每当我们发布新版本,grokbot 都会自动为我们启动一个新的 cursor 项目,对整个应用和整个构建进行模糊测试。 它会运行应用程序,像真实用户一样使用它,从而找出 bug。 然后它会为发现的每个 bug 提交一个修复 PR,并自动合并,听起来可能很疯狂。 这是因为我们的代码库质量足够好,PR 往往默认就是不错的。 而我们提交的大多数产品代码,现在基本不再需要深入的人工审查。 所以,只要有扎实的基础和良好的有机架构,你就能化废为宝,以高质量、高速度交付,同时不牺牲质量。 我叫 potato,也叫 lauren。 再次感谢大家聆听我的演讲。

Overview

Lauren Tan以Grokbot团队的实践说明,AI编程代理的高产出并不必然带来低质量代码,关键是建立可被代理遵循和验证的工程环境。她从代码库质量、架构约束与lint规则谈起,主张把纠正代理的经验沉淀为确定性检查,而不是不断追加说明性文字;再以运行时验证、形式化验证和UI属性测试减少人工审查负担。团队因此实现了高频发布,同时将回滚率维持在约0.5%,性能也持续改善。核心启示是先打牢代码与验证基础,再自动化扩张,否则只会更快地产生更多问题。

Chapters

00:42 以信任为目标建设代理环境

代理让更多工程师都能像高产能“编码机器”一样工作,因此软件工程的重点转为在提升产出的同时维持或改善代码质量。Tan将这项工作概括为建立信任,而不是盲目信任代理;团队花了六个月才达到每月交付数千个PR的状态。她提出一个倒金字塔:先依靠代码本身的确定性基础,如API设计、架构、重构、lint、类型系统、编译器和测试;再用运行时及形式化验证检查系统性质和代理是否理解目标;最后才叠加需要判断力的规则、技能和代理配置。纠正代理时,应优先把要求转化为代码中的可重复检查,而不是继续添加文字规则。

代理环境的层级结构示意图

03:27 把代码库当作代理学习的花园

代码库是代理最重要的输入之一,代理会把其中已有的惯例当作范例。代码过去可能每次只增加几个PR,如今可以连续涌入,工程师面对的规模相当于数百甚至数千个代理,因此维护代码库像是在照料花园:架构约束是新代码生长的基础,反模式、临时绕行、废弃代码和技术债则可能被代理复制并迅速扩散。要让代理持续产出好代码,必须尽量清理既有问题,让良好模式成为最显眼、最容易复用的范例。

代码库与花园的类比
代码过去以少量拉取请求到达
回顾同事提交的三个拉取请求
如今拉取请求数量约为300
每位工程师对应大量代理

05:00 用架构和lint规则消除易错选择

Grokbot团队创建的Dune客户端框架把桌面应用开发经验编码为约束和lint规则。需要细腻判断的API容易被代理误用,例如React的useEffect,因此团队禁止在产品代码中使用,只允许在Dune API的特定位置使用,从源头消除一类问题。另一个例子是Electron主线程与渲染线程:团队以明确的顶层目录区分两者,并通过依赖图分析器和lint禁止跨线程导入,避免主线程代码进入渲染线程造成长任务和卡顿。这些约束减少了代码审查时需要人工辨认的事项。

展示在产品代码中禁用 useEffect 的规则
展示通过目录结构表达上下文的架构模式
展示 Electron renderer 与 main 两个顶层目录
展示依赖图分析器和 lint 规则禁止跨目录导入

06:56 用可执行规则取代评论和文字例外

代理可能在文档、注释和规则中为不正确的做法寻找理由,也可能把一次小修正过度概括成永不破例的硬规则。Cursor中的案例显示,代理用setTimeout、requestAnimationFrame等定时器修补VS Code命令式风格与React声明式风格之间的架构冲突;大量定时器带来垃圾回收、卡顿等性能问题,而评论又为这些临时做法辩护并随之扩散。Grokbot因此禁止绝大多数注释,并用能指出根因的lint错误信息引导修复。每次纠正代理,都应考虑把经验变成确定性检查,或通过更好的API与架构从根本上消除问题;当可审查事项足够少时,代理便能自行合并更多PR。

标红的代码注释为快速修补作出辩解
Lint 错误信息引导智能体修复根本原因

09:40 通过运行时、形式化和UI测试验证代理产出

团队的代码审查逐渐转向检查验证产物,如视频、截图、图表和形式化验证结果。运行时验证让代理能够自行运行应用并使用Chrome DevTools协议等调试工具;“feature map”则从用户视角列出应用功能,为需求提供共同词汇,避免代理猜测“左侧边栏那个东西”指什么。自定义CLI和驱动可以重复利用、降低token开销,也便于测试。形式化验证方面,团队用TLA+对跨设备和平台的通知流程做模型检查,用Lean证明特定算法,并检查自研虚拟化库是否会闪烁或抖动;形式化方法已发现一些bug,但仍只是验证体系中的一层。团队也在用Bombadil进行UI属性测试,并已捕获一些UI问题。

展示应用功能地图及其面向用户的功能结构
展示使用 TLA+ 对跨设备和平台的通知流程进行形式化检查
展示用 Lean 检查虚拟化库中的闪烁或抖动问题
展示用于 UI 的基于属性测试方法
展示 Bombadil 测试库及其发现 UI 缺陷的结果

11:52 验证投入与状态图审查

代理是否值得信任,取决于能否可靠地验证其产出;Tan观察到,团队大部分token消耗都用于验证,另有工程师将每日token的70%用于验证。代码检查、测试和形式化验证并非新技术,但过去常因难以理解、编写或维护而成本过高,代理降低了这些成本,使更广泛的测试与验证变得经济。形式化方法还可以帮助明确产品行为及代理是否理解目标。Tan在pstack插件中开发了state chart技能,从用户视角展示状态机,并认为它与视频、截图一起审查更容易。

从用户视角可视化状态机

13:23 高吞吐与低回滚率并存

Grokbot团队上月向生产环境交付了11,000个PR,稳定客户端版本约每天发布一次;核心团队产出增加,临时贡献者也更多,10月有227人至少提交过一个PR。尽管提交速度加快,回滚PR的比例仍约为0.5%,且相对回滚数量更低。应用的启动、输入、打开新聊天和切换聊天等性能指标也比发布时有所改善。团队指出,Grokbot仍是Electron应用,性能存在上限,但在如此高的交付速度和贡献者规模下,整体表现仍然良好。

展示上月生产环境合并的拉取请求数量
展示十月贡献者人数
展示回滚比例约为百分之零点五且保持稳定
展示 Grokbot 性能多方面提升

15:11 先打牢基础,再建设软件工厂

在自动化之前,应先通过改善代码库、添加lint规则阻止反模式复现,并清理旧有问题,同时建立强健的验证流程;若内层编码循环持续产出劣质代码,自动化只会更快放大问题,还会迫使团队投入更多昂贵的token。具备代码质量、静态分析和运行时验证等基础后,才适合构建外层自动化。Grokbot可以启动Cursor云端代理和项目,协调数百乃至数千个代理;例如每次发布后自动启动项目对整个应用进行模糊测试,代理像真实用户一样操作、发现问题、提交修复PR并自动合并。能够这样做的前提是代码库足够可靠,使PR通常能默认保持良好。

代表先打牢代码基础、再进行自动化的核心观点

Conclusions

01:32 代理环境的信任应建立在高质量代码、架构约束和确定性验证上,而不是依靠盲目信任或不断增加文字规则。

09:10 每次纠正代理,都应尽可能将经验沉淀为可执行的确定性检查,或通过API设计和架构从根本上消除问题。

11:25 运行时验证、形式化验证和测试能降低人工审查负担,但形式化验证只是代理工程环境中的一层工具,并非万能解法。

15:11 在扩张自动化之前先改善代码库并建立强验证流程,否则自动化只会更快地产生更多劣质代码。

All Code Is Slop (Except Mine) — Lauren Tan, SpaceXSI · Video Summary · OctSum