What it takes to set intelligence free — Fabian Hedin, Lovable

Loading slides…

Read the talk

What it takes to set intelligence free

Lovable’s first multi-agent framework made the product worse. Fabian Hedin traces the return to agents through a runtime that can hand off long tasks, sandboxes that can resume and fork, and feedback from both the running app and the business it serves.

From a talk by Fabian Hedin

At a glance

Ideas worth remembering

  • The append-only trajectory gives Lovable three ways to use the same events. Agents can fork from a shared parent, the runtime can render a prompt for a particular model, and the debugger can reconstruct an earlier UI state.

  • There are two kinds of state to recover between turns. The task history lets a new worker continue the agent’s work. A computer checkpoint restores the project’s files, memory and processes.

  • Copy-on-write makes starting more drafts cheap in RAM. The memory cost as they diverge depends on which pages their processes write.

  • During a turn, the running preview can expose a software error in time to fix it. Between turns, production signals such as conversion can help decide which working change is worth keeping.

Why Lovable shelved its first agent framework

In 2023, GPT Engineer could build a one-page app with one model call per user message. The interface already had the two halves Lovable would keep: a chat to describe what to build and a preview to see the result. The setup worked for simple apps. Fabian Hedin, Lovable’s co-founder and CTO, recalls nearly running the company out of money by building for the more capable models the team expected to come next.

The team built what Hedin still calls a “beautiful” framework. A main agent spoke to the user and spawned specialists. One implementation agent could generate the first version of an app, with frontend and backend agents handling their own areas. The agents sent messages back and forth to coordinate. The extra machinery made the product worse, a regression Hedin attributes to what the models could handle at the time.

In late 2024, Lovable went back to a simpler division of labor. Smaller models retrieved information. One main model spoke to the user and wrote the code in the same message. The UI felt responsive, the system was reliable enough for users to iterate with it, and the multi-agent framework went away. As models got better at handling more complex agentic work, Lovable had reason to try orchestration again.

0:140:17

From chat and preview to running a business

The interface still starts with intent on the left and a running preview on the right. As that interface began to support more complex software, users could spend more of their time on architecture and visible behavior. A working preview is an early outcome. A product that serves customers and can make money needs more of the stack within reach.

  • Building software. The coding agent can exercise the app in a browser to check its work. It connects to GitHub so users can take and use the code it writes.
  • Running the app. The platform gives the agent databases, authentication, storage, backend compute, security scanners, backups and logs. The agent can inspect those services while working on the app.
  • Operating the business. The agent can help with receiving payments, sending emails, improving search visibility, running ads on Google and Meta, and using product analytics to examine conversions. Those same services can feed observations back into later work.
4:034:08

An inbox for agents already at work

A short dark Before bar represents 30 minutes. A long multicolor Now bar represents 10+ hours on an axis marked from 0 to 10 hours.Open full source frame
Lovable capped agent runs at 30 minutes because it doubted agents could work reliably for longer. Hedin says Lovable lifted the cap, a change the chart illustrates with a bar stretching past 10 hours.

Lovable used to stop agents after 30 minutes because the team doubted they could work reliably for longer. It removed that time cap. A task lasting 10 hours or more illustrates what the architecture now has to support. The runtime must carry the task forward, the sandbox must keep the software runnable, and the agent needs feedback soon enough to correct a bad turn.

Each agent gets its own inbox. A person, another agent or a scheduled system event can send it a message. Suppose someone asks “what’s the status?” while the agent is working. In Hedin’s example, the agent has a request, a tool call and its result in its task history by the time it is ready to receive messages. The status question waits in the inbox until the agent copies it into that history. Lovable calls the history a trajectory.

7:557:57

Forking the task history

The trajectory is an append-only log inspired by Git. Each new event points back to its parent, the previous event on that branch. To start two agents from the same point in a task, give the first event on each branch the same parent. Both agents inherit the earlier events without copying them, then build up their own histories as they work.

Lovable leaves divergent trajectories separate because the meaning of merging two sequences of actions is unclear. The agents can still exchange findings through messages.

Two trajectories with the same parent

Earlier eventPart of the history before the fork.
Shared parent eventThe point in the history where the continuations split.
New event on branch AOne agent’s continuation.
New event on branch BA parallel continuation from the same task state.
Which events do the two agents share? Follow either branch’s parent pointer and you reach the same earlier records.
Read the diagram as text
  • Earlier event. Part of the history before the fork.
  • Shared parent event. The point in the history where the continuations split.
  • New event on branch A. One agent’s continuation.
  • New event on branch B. A parallel continuation from the same task state.
  • Shared parent event → Earlier event: points to previous event.
  • New event on branch A → Shared parent event: points to parent.
  • New event on branch B → Shared parent event: points to parent.
10:1310:21

One event history feeds prompts and the debugger

A trajectory keeps tool calls, their successes and failures, and other platform events. The runtime builds the prompt from that fuller record. When a history gets long, it can summarize the early steps to fit the model’s context window. A model with more room can keep more of that history in detail, and a different task can call for a different prompt. Those rendering choices leave the original events available.

The debugger uses the same history to reconstruct the interface. The recording shows Hedin dragging a slider through a run with 156 events. As he moves the slider, the UI on the right updates to show the corresponding point in the run. The event position controls what the debugger renders, so an engineer can inspect an earlier state after the agent has moved on. 12:29

A new worker can pick up the next turn

The worker that runs an agent is almost stateless. It persists progress to the task history between turns, so another process can pick up the same task from that record. The agent’s work can span several worker processes and several versions of the runtime.

Hedin puts Lovable’s deployment rate for this system at 700 times a day, about once every two minutes. A 10-hour customer task can outlast many deployments. With turn-by-turn persistence, a worker from a new deployment can take over the next turn. The team can roll out a feature or an urgent fix without waiting for the customer’s task to finish.

13:1013:12

Checkpointing the computer, including its running processes

The agent also needs the computer where it edits files, runs a development server and verifies the app. After trying several sandbox vendors and designs, Lovable built around checkpoints. A new project starts from a shared golden checkpoint with an operating system, system services, common tools and a dev server ready to start. The checkpoint captures disk, RAM and running processes. Hedin puts the time to provision from that base at about 230 milliseconds.

Once the project has its own code and dependencies, Lovable saves a project checkpoint at the end of each agent turn. It can stop an idle sandbox to save resources and restore that computer in under a second when someone comes back. Hedin gives a user stepping away for about 10 minutes as an example. He also says the setup preserves requests already in transit, though the talk leaves the handling of those requests unspecified.

8:3314:40

Sandbox forks share RAM until a write

A checkpoint can also start more than one computer. Lovable’s drafts feature uses that ability to let users work in separate environments from the same starting state. Hedin gives an example with two drafts at once. At a larger fan-out, the cost of copying every sandbox’s memory would add up quickly.

Copy-on-write makes the initial fork nearly free in RAM. Both drafts can read the same page. If draft B writes to it, the system copies that page for B and applies the write to its copy. Draft A still sees the original contents. New RAM is allocated page by page as the drafts write.

A separate optimization helps when a checkpoint’s memory is cold. A sandbox needs a few hundred megabytes of RAM, and moving all of it from object storage through disk into the VM can take a few seconds. Lovable streams the memory so the machine can start before the full transfer finishes. The operating system gets its memory first, and other processes can start working as the memory they need arrives.

What two drafts see when one writes

Draft AAt the fork — Reads the checkpoint’s page.
Draft BAt the fork — Reads the same page.
Shared pageAt the fork — One copy in RAM.
Draft AAfter draft B writes — Keeps reading the original page.
Draft BAfter draft B writes — Reads and writes its own copy of this page.
Original pageAfter draft B writes — Still contains the checkpoint’s contents.
Private pageAfter draft B writes — Newly allocated in RAM, with draft B’s change.
Which draft sees the change? Draft B’s write creates a second copy of just that page. Draft A still reads the original.
Read the diagram as text
  • Draft A. At the fork — Reads the checkpoint’s page.
  • Draft B. At the fork — Reads the same page.
  • Shared page. At the fork — One copy in RAM.
  • Draft A. After draft B writes — Keeps reading the original page.
  • Draft B. After draft B writes — Reads and writes its own copy of this page.
  • Original page. After draft B writes — Still contains the checkpoint’s contents.
  • Private page. After draft B writes — Newly allocated in RAM, with draft B’s change.
  • Draft A → Shared page: reads.
  • Draft B → Shared page: reads.
  • Draft A → Original page: reads.
  • Draft B → Private page: writes.
16:1616:19

Rewriting Vite in Rust brings the preview up sooner

Lovable forked Vite, the JavaScript ecosystem’s development server, and rewrote it in Rust. That let the team drop the dev server’s Node.js dependency and run a Rust binary. For Lovable’s setup, Hedin reports a twofold startup speedup, a drop in time to preview from 14 seconds to 3 seconds, and a memory footprint about one-sixth of its former size, a 6.5-fold reduction.

Owning the dev server also gives the team control over how it writes to memory. Every write to a shared page can trigger a copy in a fork, so the write pattern affects how much memory several sandboxes can keep sharing. With cheaper forks, parallel agents can try different fixes for the same bug or explore different ways to improve an app’s performance.

18:0818:10

Checking the software during a turn and the product between turns

A running sandbox gives the agent feedback while it can still change course. In this inner loop, the agent can check whether the build works, look for lint and type errors, and inspect runtime errors in the preview. A headless browser in the sandbox lets it open and explore the web app, so it can respond to behavior that only appears once the code runs.

The outer loop runs between turns, after the agent yields back to the user. Once the app is in production, visitor behavior and what users say online can inform the next change. In Hedin’s A/B test example, the agent could change a piece of copy and compare conversion between the two versions. The build and browser checks can establish that the variant works. Conversion data can help decide whether to keep it.

That is where the business tools feed back into the agent. When an app takes payments through the platform, Lovable can track transactions and conversions and give the agent those signals. A subsequent turn can use them to help the user decide what to change in the product or its business strategy.

Agents talking to agents are back in production. Lovable can give each agent a computer or let several agents use one, and Hedin puts production throughput at over a billion tokens per minute. For the user, all of that still starts by describing a change in chat and watching it take shape in the preview.

19:2119:24
Transcript download
Full transcript

Loading transcript…