00:12 从多智能体失败到重新采用智能体
Lovable 在 2023 年的 GPT-4 时代认为智能体是未来,于是构建由主智能体协调前端、后端等专职智能体的复杂框架,但当时模型智能不足,产品反而变差,公司也险些失败。2024 年底团队回退到更简单的链式系统:小模型负责知识检索,主模型在同一消息中回复用户并编写代码,响应更快、更可靠。随着模型能力提升,Lovable 再次将智能体投入生产,Hedin 称相关系统每分钟处理超过十亿 token。
AI Engineer · 22:25
Welcome everyone, glad to be here. I'm Fabian, co-founder and CTO of Lovable. And we spent the last three years or so building a platform to let anyone create software and then operate that and deploy that software. And the topic of today is what it takes to set intelligence free. really, for us, this takes us back to when we started three years ago. and i have to say, i have a bit of a complicated relationship with agents. and i'll tell you why. we almost failed as a company because we thought back in 2023 that, hey, these agents are the future. so let's build for them now. i think we kind of turned out to be true that they were the future, but we were definitely wrong on the now piece in 23. so this was back in kind of gpt-4 days. and at that time, the intelligence was simply not there to have more of these kind of complex agentic systems. but nowadays, right now, now the intelligence is actually at a place where you can really build out more complicated systems around them. and so i'll give you kind of a quick background story here of our journey in working with intelligence or these llms. and so back in 2023, we built the first version of our product. we called it gpt engineer back then. and really the ui was very similar to what it is today, where you kind of have a chat and this preview. but the ai at that point was quite simple. we just had a prompt and a response, one llm call per user message. very simple. it worked fine, but you could kind of build one-page apps and simpler applications with this. and then we thought, okay, this intelligence is going to keep on evolving, so we have to be ready for... for it as it evolves. and so we thought, let's go out and build this agentic framework. and so we went and we built this very sophisticated, dare i say, beautiful framework for agents to work. and we had kind of this one main agent that would talk to the user, and that agent would spawn other agents, like an implementation agent here in the example. and each agent could have a speciality. this agent would kind of specialize in the first generation of an app, and then you would have like a front-end agent and a back-end agent. and they would all talk to each other, send messages back and forth. and we thought, oh, this is beautiful. and there were papers around this and how well this could work. and in the end, it didn't work at all. we just made the product worse. we definitely failed on this one. but luckily, before we ran out of money, we figured out, like, hey, let's go back to a simpler system again. so in late 24, we went back to a much simpler. system where it was a bit of a chain where we had like some smaller llms doing some knowledge retrieval and then really just one main llm kind of writing to the user and writing the code in the same message. and this worked great. it was very responsive for users in the ui and it was reliable and users were kind of in it and iterating with the model. and so, let's close that down. but now, it's time again. we're back. we're so back. agents, this time, they work. and we're running them in production, over a billion tokens per minute on these systems that i'm going to talk about.
欢迎大家,很高兴来到这里。 我是 Fabian,Lovable 的联合创始人兼首席技术官。 过去大约三年,我们一直在构建一个平台,让任何人都能创建、运行和部署软件。 今天的主题是如何释放智能。 对我们来说,这要追溯到三年前我们创业的时候。 我得说,我和智能体的关系有点复杂。 我来告诉大家为什么。 我们公司差点失败,因为我们在2023年时认为,智能体就是未来。 所以我们当时就着手为智能体构建产品。 我想,事实证明智能体确实是未来,但在2023年,我们显然错在了“现在就做”这一点上。 那还是 GPT-4 刚出来的时期。 当时的智能水平还不足以支撑更复杂的智能体系统。 但如今,智能水平实际上已经达到了可以围绕它们构建更复杂系统的程度。 接下来,我会简单介绍一下我们使用智能技术,也就是这些大语言模型的历程。 2023年,我们构建了第一版产品。 当时我们叫它 GPT Engineer。 其实界面和今天很相似,有一个聊天窗口和一个预览窗口。 但当时的 AI 相当简单。 我们只有提示词和回复,每条用户消息只调用一次大语言模型。 非常简单。 它运行得不错,不过用它只能构建单页应用和比较简单的应用。 然后我们想,好吧,这种智能会不断发展,所以我们必须做好准备……迎接它的演进。 于是我们想,不如去构建一个智能体框架。 于是我们构建了一个非常复杂的,我敢说,漂亮的智能体工作框架。 我们有一个主智能体负责与用户对话,它会派生出其他智能体,比如示例中的实现智能体。 每个智能体都可以有自己的专长。 这个智能体专门负责应用的初始生成,然后还会有前端智能体和后端智能体。 它们都会彼此交流,来回发送消息。 我们当时觉得,哦,这太漂亮了。 当时也有相关论文,论述这种方式能有多有效。 但最终,它根本行不通。 我们只是让产品变得更糟了。 这次我们确实失败了。 但幸运的是,在钱花光之前,我们意识到,嘿,还是回到更简单的系统吧。 所以在2024年末,我们回到了一个简单得多的 系统。它有点像一条链:一些较小的大语言模型负责知识检索,然后基本上只有一个主大语言模型,在同一条消息中回复用户并编写代码。 这个方案效果很好。 它在用户界面中响应非常迅速,也很可靠,用户能够参与其中,与模型一起迭代。 那么,我们把它关掉。 不过现在,又到时候了。 我们回来了。 我们真的回来了。 智能体,这一次,它们真的能用了。 而且我们正在生产环境中运行它们,在我接下来要讲的这些系统上,每分钟处理超过十亿个 token。
but first, just looking at, okay, what is actually lovable? if you simplify the ui, and this was the same back in 2023 as it is today, to the left we have a chat where humans come in and they kind of describe their intent to build or whatever they want to do. and to the right, you have a preview, which is the output or the outcomes of what you're building. and this back in 23, you could do simpler things with, right? but now we've really seen... working at this layer of abstraction, you're able to build very complex things, right? and i think we've even seen a lot of tooling meant for developers, for example, moving to this type of interface where you're not really looking at the code every day and so on, and you're getting kind of abstracted and working on the architecture or looking at some kind of output of what you're doing. this is something that we've always believed in and it's been kind of a core thesis behind lovable that you won't have to care about the code in the same way that you had to do before. and i think today we're kind of in this almost a bit in between, i think, in the industry where some people might say, oh, you don't have to care about code at all. and some people might have different opinions. i, of course, like growing up coding and these things, you get a bit attached. but in the end, what matters is actually not the code. sorry, i thought we removed that last part. but what matters is the outcomes, right? and so the outcomes, what is that? well, for our users, the outcomes is creating a business and monetizing and creating value for others in some type of way. and i'll kind of quickly go over what we build as a platform to enable this before i go in kind of on the technical side of this talk. so if you look at lovable, the first thing that you can say about the platform is that we have this agent. and like any other agent, it can do quite arbitrary things. and it's quite specialized at building software. and it has access to a browser so it can verify what it's building. it connects to github and it writes code and you can do whatever you want for that code. so that's kind of your basic coding agent. and the other pieces of the platform is this kind of cloud and business piece of the platform. and so the cloud part of the platform is about just giving kind of these hosting primitives just seamlessly to this agent. we built out databases, authentication, storage, all the type of backend compute and security scanners and like backups and logs for all of these things. and all of it can be introspected by the agent. and this just makes it seamless to build things. you don't have to kind of go to different services to set this together. we just kind of provide you these primitives. so that's still around building software and hosting this, right? but then the last piece is around these business capabilities where, again, the output of what our users are doing on lovable, we don't see that output as code. the output is a product or a business. and if you want to succeed as a business, you need to do more things than just write code, right? and so we help our users with receiving payments, sending emails, optimizing seo. doing ads on google and meta and kind of analyzing what is happening with the product through analytics and you can look at kind of conversions and optimize these sort of things and the agent is in the loop in all of this, right? so that's kind of our capability offering, you could say. and again, the core part of this is an agent that all of these capabilities are built for.
但首先,让我们来看看,Lovable 到底是什么? 如果简化一下这个界面,从 2023 年到今天一直都是这样:左边是聊天窗口,人们在这里大致描述自己想要构建什么,或者想做什么。 右边则是预览,也就是你正在构建的东西所产生的输出或成果。 在 2023 年,你可以用它做一些比较简单的事情,对吧? 但现在我们确实看到……在这个抽象层上工作,你可以构建非常复杂的东西,对吧? 我觉得我们甚至看到,许多面向开发者的工具也在转向这类界面:你不再每天盯着代码,等等,而是在一定程度上从代码中抽象出来,着手设计架构,或者查看工作产生的某种输出。 这是我们一直以来相信的,也是 Lovable 背后的核心理念之一:你不必再像以前那样关注代码。 我觉得如今整个行业在这方面还处于一种中间状态:有些人可能会说,哦,你完全不必关心代码。 也有人可能持有不同的看法。 当然,我从小编程,做这些事情,难免会有点感情。 但归根结底,真正重要的不是代码。 抱歉,我以为我们把最后那部分删掉了。 但重要的是成果,对吧? 那么成果是什么呢? 对我们的用户来说,成果就是创建企业、实现盈利,并以某种方式为他人创造价值。 在深入这次演讲的技术部分之前,我会先快速介绍一下我们构建的平台是如何实现这一点的。 所以,如果你看看 Lovable,首先可以说的是,我们的平台有这样一个智能体。 和其他智能体一样,它能做各种各样的事情。 而且它特别擅长构建软件。 它还能使用浏览器,所以可以验证自己正在构建的东西。 它会连接到 GitHub 并编写代码,而你可以随意处理这些代码。 这基本上就是一个编程智能体。 平台的其他部分包括云服务和业务功能。 平台的云服务部分,就是无缝地为这个智能体提供基础托管能力。 我们构建了数据库、身份验证、存储、各种后端计算能力、安全扫描工具,以及所有这些功能的备份和日志。 智能体可以检查所有这些内容。 这让构建产品的过程变得非常顺畅。 你不需要去不同的服务上把这些东西拼凑起来。 我们会直接为你提供这些基础能力。 所以这些仍然是围绕软件的构建和托管,对吧? 最后一部分则是这些业务能力。再说一遍,我们并不认为用户在 Lovable 上做事的产出是代码。 产出是一款产品或一门生意。 而如果你想把生意做好,需要做的不仅仅是写代码,对吧? 所以我们帮助用户收款、发送邮件、优化搜索引擎排名。 在 Google 和 Meta 上投放广告,通过数据分析了解产品的运行情况;你还可以查看转化情况并优化这些方面,而智能体会参与整个过程,对吧? 可以说,这些基本上就是我们提供的能力。 再说一次,这一切的核心是一个智能体,所有这些能力都是为它构建的。
and at some point in Lovable's history, we used to limit our agents to work for only 30 minutes because we thought they weren't reliable to work for a longer amount of time. but now we've changed this to really be without any sort of bound in terms of the length an agent can work. and so you can imagine agents working for 10 hours plus. and so i'll go into some of the things that we've done. in our architecture to enable this. And so the first piece is really around the agent runtime itself and how we enable that to run for a long amount of time. And the second piece is the computer where each of these agents are actually doing their work, running a dev server and actually verifying what it's doing. And so the last piece then is the verification itself where if you want an agent to work for a long amount of time, you need to make sure that you have these feedback loops in place so that it's not kind of going off. in the wrong direction. and so if we start by looking at the agent runtime itself, you can imagine that you have really three different sources that can interact with an agent. so it can be yourself kind of prompting this or a human. it could be other agents and it could also be just a system on a schedule waking up. and the way we chose to architect this is that for each agent, we have a separate inbox where any of these sources would kind of send in messages. and so you might have a message here like, what's the status? and you can imagine you have this agent, and this agent is kind of an always-on agent that might be working, right? and so you can imagine it has done like three actions here, a request, a tool call, and it got some result. and then at this point, the agent is ready to actually receive messages. so since anyone can drop a message into this inbox, the agent then can copy that itself into its own, what we call a trajectory, basically its task history. and this is the type of interaction that i think you're familiar with if you're using agents overall. so that's kind of the first design principle behind this agent runtime. i'll go through a few more here.
在 Lovable 发展历程的某个阶段,我们曾将智能体的工作时间限制在 30 分钟以内,因为我们认为它们长时间工作并不可靠。 但现在我们已经改变了这一点,智能体的工作时长基本上不再受到任何限制。 所以,你可以想象智能体连续工作 10 个小时以上。 接下来我会介绍我们做过的一些工作。 也就是我们在架构中为实现这一点所做的工作。 第一部分主要是关于智能体运行时本身,以及我们如何让它长时间运行。 第二部分是计算机,每个智能体都在上面实际工作、运行开发服务器,并验证自己的工作。 最后一部分则是验证本身。如果你希望智能体长时间工作,就需要确保建立这些反馈循环,避免它偏离 正确方向。 首先来看智能体运行时本身,你可以想象,大致有三种不同的来源可以与智能体交互。 可能是你自己,或者其他人,通过提示词与它交互。 也可能是其他智能体,或者只是一个按计划唤醒的系统。 我们选择的架构方式是,为每个智能体设置一个独立的收件箱,任何一种来源都可以向其中发送消息。 比如,这里可能会有一条消息:“进展如何?” 你可以想象有这样一个智能体,它始终在线,可能正在工作,对吧? 你可以想象它在这里完成了三个动作:一个请求、一次工具调用,然后得到了某个结果。 到了这个时候,智能体就准备好接收消息了。 由于任何人都可以往这个收件箱里发送消息,智能体可以自行将消息复制到我们称之为“轨迹”的内容中,也就是它的任务历史。 如果你平时使用智能体,我想你应该对这种交互方式很熟悉。 所以这大致就是这个智能体运行时的第一条设计原则。 接下来我会再介绍几条。
and so the trajectory in which the agent is working in, which is kind of the history of what has happened so far, and really the basis for any sort of memory for the agent, right? and we designed this trajectory with really git as inspiration. and so... the trajectory, what is it? it's a append-only log where each event points towards a parent, the previous event. and because of this, you get a nice capability, just like in git, where you can fork things, right? so you can have two events pointing to the same parent, which essentially creates a fork. and because of that, you can kind of spin up parallel agents at... at any point of time in the history without having to duplicate all of the shared history. and semantically, it's a bit unclear what would happen if you merge this. so unlike git, we cannot merge agent trajectories, but we can spawn them outright and these agents can talk to each other. the other thing that we made sure to design for is that this agent trajectory, it includes kind of the full history and everything that happens with the agent. every tool call, a bunch of other things happening on the platform, if a tool call failed or succeeded, a bunch of things that might not be fully relevant for a prompt. but then what we've done is make sure that we have this append-only log, and from that we can actually build a prompt that we would feed into the actual llm. and you might ask, why would you want to do this? well, one reason is that when you build a prompt, if you have a long history, you probably want to do some sort of compaction. you want to summarize part of that history in the earlier steps, for example. but this summarization would differ. for example, if you use different models with different context lengths, you would probably think differently about when you should summarize and not. and so by separating the prompt from the actual task history, we're able to render prompts for any type of model or any type of task. that we can kind of find the best and optimal prompt for. so to show this event history in progress, we have this debug tool here. so here it's just a recording of me dragging this slider in our ui. and you can see on the right that the ui is kind of updating as i'm dragging this along. and you have 156 events here. and each of those is an event in this event history. and you can see how the ui can render kind of any point in history. and this is just showcasing that at any point in time, we have full control of, say, the ui or anything else happening on this platform, thanks to this history kind of detailing everything that has happened.
智能体工作时所处的轨迹,大致就是迄今为止发生过的事情的历史,也是智能体各种记忆的基础,对吧? 我们设计这个轨迹时,主要借鉴了 Git。 那么……轨迹是什么呢? 它是一个只能追加内容的日志,其中每个事件都指向一个父事件,也就是前一个事件。 正因为如此,你就获得了一项很实用的能力:和 Git 一样,你可以创建分支,对吧? 也就是说,你可以让两个事件指向同一个父事件,这实际上就创建了一个分支。 因此,你可以在历史中的……任何时间点启动并行智能体,而不必复制所有共享的历史。 不过从语义上说,如果把它们合并,会发生什么并不太明确。 所以与 Git 不同,我们不能合并智能体轨迹,但可以直接派生出新轨迹,而且这些智能体可以相互交流。 我们在设计时还特意考虑了另一点:这个智能体轨迹包含完整的历史,以及智能体发生的所有事情。 每次工具调用、平台上发生的其他各种事情、工具调用是失败还是成功,还有许多可能与提示词并不完全相关的内容。 而我们所做的,是确保拥有这个只能追加内容的日志,然后可以据此构建一个提示词,输入给实际的大语言模型。 你可能会问,为什么要这么做? 一个原因是,构建提示词时,如果历史很长,你可能需要进行某种压缩。 比如,你可能想把较早步骤中的部分历史做个摘要。 但摘要的方式会有所不同。 例如,如果你使用的模型上下文长度不同,对何时该做摘要、何时不该做摘要,你的考虑可能也会不同。 因此,通过将提示词与实际的任务历史分开,我们就能为任何类型的模型或任务生成提示词。 这样我们就能为其找到最佳、最优的提示词。 为了展示这个事件历史的进行过程,我们这里有一个调试工具。 这里播放的是我在界面中拖动这个滑块的录屏。 你可以看到,右侧的界面随着我拖动滑块而不断更新。 这里一共有156个事件。 每一个都是这段事件历史中的一个事件。 你可以看到,界面可以呈现历史中的任何一个时间点。 这展示了我们在任何时间点都能完全控制界面或这个平台上发生的任何其他事情,这都得益于这段详细记录了一切的历史。
the last piece i'll go over here on the runtime itself is that the process that is running these agents, they're separate from the actual task history. and so the process is almost entirely stateless in that between each call, each tool call, each turn, it will actually just persist into the task history. and so you can have a process come and go. and then the question is, why do we care about this? well, at lovable, this system, we deploy to it 700 times per day. so that's about once every two minutes. and you can imagine if you have an agent working for 10 hours, you want to not disrupt that agent when it's working, right? this agent is doing something for a customer. but at the same time, we want to make sure that this agent is running on the latest deploy. and it might be a new feature or something like that, but it might also be like a security vulnerability in the linux kernel. and it's like, okay, we need to update this asap. and so to do that, thanks to this separation between the actual history and the processes, we can actually make sure that we have one agent that is working on one task, but we can have different processes taking up and actually doing the compute behind that work. Um, so, so this task can keep on working while we have, um, different deploys, um, working on it, be it for 10 hours or, or even longer, right? Um, so that's the agent runtime. The second piece of, um, of this platform, right, is the, is the computer.
关于运行时本身,我要介绍的最后一点是,运行这些智能体的进程与实际的任务历史是分开的。 因此,这个进程几乎完全是无状态的:在每次调用、每次工具调用和每一轮之间,状态都会被持久化到任务历史中。 所以进程可以随时启动或退出。 那么问题是,我们为什么要关注这一点? 在Lovable,我们每天会向这个系统部署700次。 也就是大约每两分钟一次。 可以想象,如果一个智能体要工作10个小时,你肯定不希望在它工作时打断它,对吧? 这个智能体正在为客户执行任务。 但与此同时,我们也希望确保这个智能体运行的是最新部署的版本。 部署的可能是新功能之类的东西,也可能是Linux内核中的安全漏洞修复。 这时候我们就需要尽快更新。 为了做到这一点,由于实际的历史记录与进程是分离的,我们可以让一个智能体持续处理同一个任务,同时由不同的进程接手并执行这项工作背后的计算。 嗯,所以这个任务可以持续运行,即使期间有不同的部署版本在处理它,无论是运行10个小时,还是更长时间,对吧? 嗯,这就是智能体运行时。 这个平台的第二部分,嗯,是计算机。
So this is where the work is actually happening. Um, and we've been through a lot of iterations and a lot of vendors kind of working with, um, providing these sandboxes for, for the computer, for, for the agent to work in. and we've landed in this system that we've worked really hard now to develop, which is a checkpointing a computer. and so you can imagine you come to lovable, you start a new project. we have this common, what we call a golden checkpoint, which contains the os and the system services. it has common tools installed and a dev server that is ready to start. and this checkpoint, it includes everything on disk, memory, and also running processes. and so when you start a new project, you get all of that for free. and all of that is copied over in about 230 milliseconds. and so once you start a project, you might have some specific code and some dependencies within that project. and that is also checkpointed as you go. and so each time the agent is running and it finishes a turn, we will actually save a checkpoint of that computer. and from that, we're able to, again, very quickly, sub-second, spin that computer up whenever you need it. that means we can save on resources by spinning this down if you leave for, say, 10 minutes or so and come back. we can just spin it up extremely quickly so you don't even notice this. and even requests in transit will not even be dropped in this setup.
实际的工作就是在这里进行的。 嗯,我们经历了多次迭代,也和许多供应商合作过,让他们提供沙箱,供计算机上的智能体工作。 最终,我们确定了一个现在已经投入大量心血开发的系统,也就是为计算机创建检查点。 你可以想象一下,你来到 Lovable,开始一个新项目。 我们有一个通用的、称为黄金检查点的东西,其中包含操作系统和系统服务。 它安装了常用工具,还有一个随时可以启动的开发服务器。 这个检查点包含磁盘和内存中的所有内容,以及正在运行的进程。 所以当你开始一个新项目时,就能直接获得所有这些。 所有这些内容复制过来只需要大约230毫秒。 项目开始后,你可能会在其中加入一些特定的代码和依赖项。 这些内容也会随着你的操作被保存到检查点中。 所以每次智能体运行并完成一轮操作时,我们都会保存该计算机的一个检查点。 有了这个检查点,我们就能在你需要时再次快速启动这台计算机,耗时不到一秒。 这意味着,如果你离开大约10分钟再回来,我们可以先关闭它来节省资源。 我们可以极其迅速地重新启动它,快到你甚至察觉不到。 在这种设置下,甚至连传输中的请求都不会丢失。
the other thing we can do thanks to this checkpointing is that just like the trajectory itself in the agent runtime, we can also fork the computer. and when we do this, for example, we have a feature in Lovable that is called draft where you kind of work in different environments of what you're doing. and to support that, we need to fork the computer that you're working in. and here we have kind of the example of doing two at the same time. and you can imagine doing hundreds of these, right? and so we've had to do some optimizations to make this feasible to actually run. so one of these optimizations is copy on write on the ram itself. and so creating one of these forks of a computer is basically free in terms of the ram that it's using. but as soon as you start writing in a process to ram, we will kind of copy that page over, and only then will you start having to allocate new memory. and there's another optimization here also, which is that each of these sandboxes require a few hundreds of megabytes of memory, and that would take a few seconds to stream in if you have it in like code object storage, and then it has to go to disk, and then... then into memory of this vm. but thanks to being able to stream the memory, we can actually boot up the machine before all of the memory is actually ready on it. so the memory the os uses comes first, and then like some processes and so on will start to work as soon as the memory gets there. and this also shapes off some. so makes rest startup time.
得益于这种检查点机制,我们还能做另一件事:就像可以对智能体运行时中的轨迹本身创建分支一样,我们也可以对计算机创建分支。 比如说,Lovable 有一个叫 Draft 的功能,让你可以在不同的环境中开展工作。 为了支持这个功能,我们需要为你正在使用的计算机创建分支。 这里的例子展示了同时创建两个分支。 你可以想象一下,同时创建几百个这样的分支,对吧? 所以我们必须做一些优化,才能让它实际运行起来。 其中一项优化就是对内存本身采用写时复制。 因此,创建这样一个计算机分支,基本上不会产生额外的内存开销。 但一旦某个进程开始向内存写入,我们就会把对应的内存页复制过去,只有这时才需要分配新的内存。 这里还有另一项优化:每个沙盒需要几百兆字节的内存。如果数据存放在类似代码对象存储的地方,流式加载需要几秒钟,而且还得先写入磁盘,再进入这台虚拟机的内存。 但由于可以流式加载内存,我们实际上能在所有内存数据准备就绪之前就启动机器。 操作系统使用的内存会先加载,然后一些进程等会在所需内存数据到位后立即开始运行。 这也节省了一些时间。 所以缩短了剩余的启动时间。
and then we started asking ourselves, how can we make this even more efficient and even more faster for our users? and so you might be familiar with vite, this great dev server that most of the meta frameworks out there in the javascript ecosystem is using. and so we took that and we forked it and we rewrote it in rust. and that made our cold starts two times faster. we went from getting this preview from 14 seconds to three seconds. And the main kind of thing that we made faster here is that Vite uses Node. js and we're able to like drop that dependency off Vite itself and just have this Rust binary. So that made the memory footprint be 6.5 times less in these machines. And by taking control of the applications that we're running in these computers, we're also able to control kind of how we write to memory. And so when we control how we write to memory, we're even more optimizing, if you remember back to the kind of the copy-on-write solution when we're drafting different. different computers. and so we're able to run this extremely efficiently so that we can run lots and lots of agents in parallel and kind of have agents explore different solutions to solving a bug or improving the performance of your applications and so on. and so this has been fun.
接着我们开始思考,怎样才能让它更高效,让用户用起来更快? 你可能熟悉 Vite,这是一个很棒的开发服务器,JavaScript 生态中大多数元框架都在使用它。 于是我们基于它创建了一个分支,并用 Rust 重写了它。 这让我们的冷启动速度提高了一倍。 获取这个预览的时间从 14 秒缩短到了 3 秒。 我们在这里加速的关键在于:Vite 使用 Node.js, 而我们能够去掉 Vite 本身对它的依赖,只保留这个 Rust 二进制程序。 这使得这些机器的内存占用减少到了原来的六点五分之一。 通过控制我们在这些计算机上运行的应用程序,我们也能够控制向内存写入数据的方式。 因此,当我们控制内存写入方式时,就能进一步优化。如果你还记得之前提到的写时复制方案,在我们创建不同的 不同的计算机时。 因此我们能够非常高效地运行它,从而让大量智能体并行运行,让它们探索不同的方案来修复错误、提升应用程序的性能,等等。 所以这一直是件很有意思的事。
but the last piece now is about verification. and of course, this kind of computer and this dev service is a big piece of being able to verify what an agent is doing. Um, and if you look at verification, you can think of these feedback loops, right? That the agent needs to get information, it took an action, was this a good action or was it a bad action? And um, you can think of it as this inner loop and this outer loop. So this inner loop is um, during the turn of the agent. And you have kind of obvious things such as like the um, is the build working? Do we have lint errors or type errors in the code that we're running? And then you can check for runtime errors in in the preview that you're running. You can also have within this computer a headless browser where the agent can go in and kind of explore um, the the web app it's it's building or whatever it's building, right? Um, and a bunch of other things that we're using to help verify within the turn of an agent. But then you also have this outer loop, which is kind of between each turn, and a turn you can think of like when the agent is yielding to you as a user. Um, and between each turn, you might get some info on on the product itself, uh, from from production, from your users, right? And so you can look at how your visitors are behavior are behaving, um, what users are are telling you online, uh, you can do automatic A/B tests and actually see, uh, change some copy and see is this improving conversion and so on. and then you can also take these business metrics. and remember, this goes back to kind of the capabilities i showed you. by having control over these things, we can make sure that we can optimize how the agent is getting this outer feedback loop. so we can make sure that if you're running payments, we can actually track those transactions and conversions and make sure that the agent can actually help you optimize not only the code, right, but the business strategy around your product. and so those are really the three things that we've been working for. and we'll continue to kind of build out these capabilities and this architecture around really orchestrating these llms into agents. and so this agentic system that we're building is running billions of tokens per minute. these computers, right, we can spawn up with each agent and we can have multiple agents use one computer. and now we're kind of back to this quite beautiful setup where you have agents talking to agents and they're orchestrating. and this time it's actually working and it's working at scale thanks to some of these optimizations. and so if you're curious to try this out, you can head to lovable. dev and you'll see our preview spinning up and so on. but you'll get a very simple and. A nice interface and you won't have to care about all of this stuff. Thank you so much. It's been a pleasure. And yeah, hope you learned something. Thanks so much.
但现在最后一部分是验证。 当然,这种计算机和开发服务是验证智能体行为的重要组成部分。 嗯,说到验证,你可以把它想象成这些反馈循环,对吧? 智能体需要获取信息:它采取了一个行动,这个行动是好是坏? 嗯,你可以把它看作一个内循环和一个外循环。 这个内循环发生在智能体的一个回合之内。 其中有一些显而易见的事情,比如构建是否成功? 我们运行的代码中是否存在 lint 错误或类型错误? 然后你可以在运行的预览中检查运行时错误。 你还可以在这台计算机中配置一个无头浏览器,让智能体进去探索它正在构建的 Web 应用,或者它正在构建的其他东西,对吧? 嗯,我们还使用了许多其他方法,帮助在智能体的回合内进行验证。 但还有一个外循环,大致发生在每个回合之间。你可以把回合理解为智能体完成工作并把控制权交还给用户的过程。 嗯,在每个回合之间,你可能会从生产环境、从用户那里获得一些关于产品本身的信息,对吧? 所以你可以观察访客的行为,看看用户在网上说了些什么;你还可以进行自动化 A/B 测试,比如修改一些文案,看看这样是否提高了转化率,等等。 然后你还可以利用这些业务指标。 请记住,这又回到了我之前向大家展示的那些能力。 通过控制这些环节,我们可以优化智能体获取外部反馈的循环。 这样,如果你在处理支付,我们就可以追踪交易和转化,确保智能体不仅能帮你优化代码,还能帮你优化产品的业务策略。 这就是我们一直在努力实现的三个方面。 我们会继续完善这些能力和架构,重点是将这些大语言模型编排成智能体。 我们正在构建的这个智能体系统,每分钟要处理数十亿个 token。 我们可以为每个智能体启动这些计算机,也可以让多个智能体使用同一台计算机。 现在我们又回到了一个相当美妙的架构:智能体之间相互交流、协同编排。 而这一次,多亏了这些优化,它确实运作起来了,而且能够大规模运行。 如果你有兴趣试试,可以前往 lovable。 dev,你会看到我们的预览启动起来,等等。 但你会得到一个非常简单、 美观的界面,无需操心所有这些事情。 非常感谢大家。 很高兴能和大家分享。 希望大家有所收获。 非常感谢。
Lovable 联合创始人兼 CTO Fabian Hedin 回顾了公司从过早采用复杂多智能体框架、退回简单模型链,到重新构建长时运行智能体的经历。他以产品和商业结果为目标,拆解支撑智能体的三项基础:持久化任务历史与无状态运行进程、可检查点和分叉的计算环境,以及从代码验证延伸到业务指标的反馈闭环。分享同时给出沙箱启动、内存优化和开发服务器改造的数据,为设计可靠的长期编程智能体提供实践参考。
Lovable 在 2023 年的 GPT-4 时代认为智能体是未来,于是构建由主智能体协调前端、后端等专职智能体的复杂框架,但当时模型智能不足,产品反而变差,公司也险些失败。2024 年底团队回退到更简单的链式系统:小模型负责知识检索,主模型在同一消息中回复用户并编写代码,响应更快、更可靠。随着模型能力提升,Lovable 再次将智能体投入生产,Hedin 称相关系统每分钟处理超过十亿 token。
Lovable 的界面以聊天接收用户意图,以预览展示成果;Hedin 认为重要的最终成果不是代码本身,而是能创造价值和收入的产品或业务。平台结合可访问浏览器、连接 GitHub 的编程智能体,以及数据库、认证、存储、计算、安全扫描和日志等云能力;支付、邮件、SEO、广告和分析功能则让智能体参与产品转化与业务优化。
Lovable 曾因可靠性顾虑把智能体运行时间限制在 30 分钟,后来取消时长上限,目标是支持十小时以上的任务。长期运行依赖运行时、执行工作的计算机和验证反馈循环。每个智能体都有独立收件箱,接收人类、其他智能体或定时系统的消息,并在准备处理时把消息纳入自己的任务历史。
智能体轨迹是受 Git 启发的追加式事件日志,每个事件指向前一个事件,因此可以从历史任意位置分叉出并行智能体而不复制全部共享历史;轨迹目前不能合并,但智能体可以相互通信。完整历史保留工具调用及其结果等事件,实际提示词则从历史生成,可根据模型上下文长度和任务需要压缩或总结。调试工具还可通过事件历史还原界面的不同状态。
执行智能体的进程与任务历史分离,每次调用、工具调用或轮次之间都会持久化状态,因此进程可以更替,由其他进程继续同一任务。Hedin 称该系统每天部署约 700 次;这种设计既能避免长达十小时的客户任务因部署中断,也能让任务使用最新功能或安全更新。
新项目从包含操作系统、系统服务、常用工具和就绪开发服务器的黄金检查点启动;检查点覆盖磁盘、内存及运行中的进程,复制约需 230 毫秒。智能体每轮完成后还会保存项目计算机检查点,使闲置环境可以关闭并在需要时于一秒内恢复,连传输中的请求也不会丢失。
检查点使计算机能够像智能体轨迹一样分叉,Lovable 的 Draft 功能用它支持不同工作环境。内存采用写时复制:分叉初期共享 RAM,只有进程写入时才复制相应页面并分配新内存。系统还流式加载内存,优先提供操作系统所需部分,让机器不必等全部内存就绪才启动,以缩短恢复时间。
团队分叉 Vite 并用 Rust 重写,移除 Vite 本身对 Node.js 的依赖。Hedin 称冷启动速度提高两倍,预览出现时间从 14 秒降至 3 秒,机器上的内存占用减少 6.5 倍;控制应用的内存写入方式还可进一步优化写时复制,为大量并行智能体探索修复或性能方案提供支持。
智能体轮次内的验证包括构建、lint、类型检查、预览运行时错误以及通过无头浏览器探索应用;轮次之间则可获取生产环境中的访客行为、用户反馈和 A/B 测试结果。支付交易、转化等业务指标进入外层反馈循环后,智能体不仅能优化代码,也能协助调整产品的商业策略。
01:12 复杂多智能体架构的有效性取决于模型能力,过早构建可能让产品变得更差。
08:20 长期运行的智能体需要持久任务历史、可恢复的计算环境和持续验证的反馈循环共同支撑。
12:11 将完整任务历史与提示词分离,可以按模型和任务需要生成或压缩上下文。
14:08 将任务历史与执行进程分离,可在频繁部署时延续长时间运行的智能体任务。
17:01 计算机检查点、写时复制和流式内存加载使沙箱能够快速恢复并高效分叉。
20:50 智能体的反馈目标可以超越代码正确性,延伸到产品转化和商业策略。