transcribe

Browsers for Coding Agents - Victoria Klein, Lovable

Browserbase · 23m · transcribed 17d ago
More from Browserbase Business
𝕏 Share ▶ YouTube 📥 PDF 🤖 .md

Section Insights

# 0:00

Introduction to Browser Interactions at Lovable

What is the role of browsers in Lovable's coding agent?

Vic Klein introduces the concept of browser interactions within Lovable's coding agent, emphasizing the importance of verification in the development of full-stack applications.

  • Lovable's core agent interacts with browsers to build full-stack applications.
  • Verification is crucial for ensuring the agent performs as claimed.
  • Browser use is integrated into the core workflow of Lovable's applications.
# 4:42

The Importance of Verification

Why is verification critical for user trust in applications?

Verification is essential to maintain user trust, especially for non-technical users. The agent must balance the appetite for verification with the demand for it to avoid over- or under-verification.

  • User trust can be significantly impacted by the verification process.
  • Balancing verification appetite and demand is key to effective agent performance.
  • Over-verification can waste resources, while under-verification can damage credibility.
# 9:24

Cost Implications of Verification

How does verification impact operational costs?

Verification processes can lead to significant costs due to token usage, especially when unnecessary interactions occur. Efficient management of these processes is crucial to avoid excessive spending.

  • Token costs can escalate quickly with inefficient verification processes.
  • Understanding the cost dynamics of verification is essential for managing budgets.
  • Excessive verification can lead to thrashing, increasing operational costs.
# 14:06

Model Performance and Verification Outcomes

How do different models perform in terms of verification?

Different models exhibit varying tendencies towards over- and under-verification, impacting their overall effectiveness. The performance of these models can be assessed by their ability to complete tasks satisfactorily.

  • Models can either over-verify or under-verify, affecting task outcomes.
  • Token efficiency plays a role in the likelihood of thrashing versus under-verification.
  • Evaluating model performance requires looking beyond verification rates to actual task success.
# 18:48

Understanding Agent Behavior in Verification

What factors influence an agent's decision to verify?

The agent's own actions significantly influence its verification decisions, with a majority of verification behavior driven by its internal reasoning rather than external prompts.

  • Agent behavior is largely self-determined, impacting verification decisions.
  • Contextual factors have less influence on verification than previously thought.
  • Improving verification processes may require focusing on agent behavior rather than just prompting.

Transcript

0:03 here to talk about browsers for coding agents, the two tales of verification. Please welcome to the stage Vic Klein. I'm Vic. I am a member of technical staff at Lovable and I'm here to essentially talk about the core agent that powers Loveable. I work on the core harness at lovable and do a lot of model evaluations and one of the things level does is interact with the browser because lovable builds applications that tend to be full stack. So yeah, maybe a short overview of what we're going to cover. the first is I'm just going to give you a quick rundown of how browser use kind of works at lovable or for Lovable I should say if I'm personifying it.

0:49 what I really mean by verification, why we actually care about these two tales that we see in terms of behavior, how we measure it and how we sort of aim to move the needle with respect to those metrics. so yeah, the main thing here being verification, which is describing what that looks like in practice, the challenges that come with it. and yeah, so browsers at Lovable, Lovable is actually ostensibly a coding agent at heart. I'm not really sure if that comes across, in the product because it can do many, many different things, but, really, it builds full stack applications, allowing users to kind of build, run, and grow. it's actually, built on quite a a code, premise and sort of foundation.

1:41 increasingly so despite its like myriad of capabilities and as such browser interactions and browser use forms part of the sort of core workflow that the lovable agent engages with as people build their applications. so yeah in the lovable harness the browser is a shell command. It is not a tool. So, we don't use JSON, like essentially standard JSON tools for browser use. and that's a pretty opinionated choice. but really like the slide is sort of backwards. What you want is the bottom three things. We want our agent to be able to visually verify changes. We want our agent to be able to measure sort of reading layouts from the DOM, reproducing a certain workflow.

2:30 We also very much want our agent to be able to debug and check the environment, read runtime errors, console logs. And so really it engages with this like very sort of code execution fast workflow where it can write short playright scripts use CLIs, navigate, click, wait, all of that. It can observe, it can sort of look at screenshots. those scripts give it a lot of flexibility in terms of what it can interact with in the browser. we also extensively pipe console logs network logs runtime logs, build errors, type check errors, all of this into files. so it's like very file system first which it can grap and read through. So we're really quite keen on reducing the load on the sort of like core set of tools. and allowing it to increasingly do its thing via code execution basically. So just to give you some question of scale we have about in one production day 2.4 million agent turns. So by turn I mean a user sends a message with a specific task and that runs through us and about one in five will interact with the browser in some way. So that's quite a heavy load for us and because these tend to take longer than your standard agentic turns interacting with the browser around two and five of the time agents spend in flight belongs to those turns where it interacts with the browser. and that accounts for roughly 7% of all our shell executions for the main agent in a single day which is about 1.75 million tool calls.

4:17 So we have a lot a lot of tool calls and we try to keep a fine grained sort of finger on the pulse of what's happening inside the sandbox because it's very code execution first and that includes what happens with the browser. so verification verification is essentially the term we use to encompass the previously mentioned seeing u measuring and debugging and the interaction with the browser. So, this is like particularly important for front-end applications, especially when serving nontechnical users, is to essentially make sure the agent has actually done what it claims it's done. it can cost a lot in user trust, and we really try to do our best to ensure that things are verified. and here we're talking about that with respect to the app that Loveville is building for the user. so really a request comes in from a user. It can be a myriad of different things. And we want to essentially like it's I suppose the joint job of the model and the harness to match the appetite for verification with the demand for verification. And I'll give you an example of what I mean by what an agent does when it verifies things in a second. but by and large the diagonal here is where appetite meets demand. So the necessity for the agent to take screenshots, read console logs, all of this costs tokens. it sits in our context window and we want to make sure that that's only happening when it's actually necessary. if not, it burns tokens for us and like trust and credibility with the user. and that would be the sort of top leftand corner which is where we have a lot of overification. So these are tail behaviors. The intensity of the color here basically refers to like the bulk of the density probability distribution.

6:09 So the majority sits on the diagonal. We match appetite and demand quite well. But we have these two tail behaviors which is the top left which is over verification. Then we have underverification where a model is basically like yeah no cool done that. thank you next. And this is really where we see a lot of trust burn. and that's the bottom right hand corner. And the pendulum is basically that you can ask an agent for more verification and we start to see this regular appearance of thrashing and looping and sort of anxiety essentially. and I'll show you later that this happens to actually differ quite a lot based on model family or provider. And if we remove the ask for verification, we essentially get a sort of wild west I've said I've done it. Who cares? which is just kind of not acceptable.

7:02 So thrashing is the term we use for over verification internally and like I'm going to give you an example of like a little term which is okay we did a visual fix one screenshot cool oh wait I need to tweak something another screenshot okay wait a minute there's a timeout with the browser the screenshot didn't work let's rememeasure it via the DOM okay let's take a final screenshot just to be really sure and eventually we basically work our way up from this diagonal into like a thrashing loop that actually costs users and us quite a bit.

7:36 and you can imagine if this happens continuously. this is pretty pretty bad for everyone. And so our job is to essentially understand why these tail behaviors happen and to try and curb them and keep the bulk of the traffic in the middle. and yeah, this is essentially the same as saying every redundant to the from the model's perspective is locally justified, right? There's a timeout. Cool. I'll try again. I've made a change. Great. I need to re screenshot. But really, when it stacks up globally, you start to see a lot of looping and an increasing level of anxiety as as the the turn runs on.

8:15 so why do we actually care? We we you know when I myself like personally develop I would way rather just know and everything's verified and that's brilliant and use a hundred like agents in a sub aent swarm or a dynamic workflow and that's brilliant and I know it's all verified. the main reason is tokens. around one in three turns that use the browser use it three or more times. So interact with it multiple times. and around 77% of all those like browser runs, so e like script executions for browsing happen inside these like really long thrashing turns.

8:55 So you can see this is like an enormous concentration of browser use in like not many turns. and you'll see that basically translates into an enormous amount of tokens being spent in these thrashing thrashing loops. So it's like you know tail behaviors but really actually not tail tokens. and that's quite a big problem for us. and we want to make sure we're sort of like evaluating models and understanding their behavior with respect to this.

9:27 so yeah this is about 5% of tokens of all our traffic for the main agent spend are spent in these like flashing turns. so yeah in one day of production traffic you can see that we essentially have roughly 5% just in terms of tokens spent in these turns where it's sort of eight or more interactions with the browser. and some of these very rarely are warranted if the users requested let's say yeah I really want you to go hell for leather and just check everything out. some of these are really not warranted and we really want to keep an eye on that.

10:02 and as you can see like token growth really really scales with that. So this might look like a small percentage in terms of traffic but it can be a very big percentage in terms of spend. so yeah, why is this so expensive? I think if anyone runs an agent in production, they understand the fact that once you put something on a context window in the context window, if you're going to keep it there, it costs you a lot more money as time goes on. and that's really because you're paying for in best case scenario output and cache reads every single time. Worst case scenario, cash writes. and taking it off the context window is equally expensive because you're going to break the prefix and you're going to pay for it. So, this same turn that I showed you previously, sort of working its way up into a thrash. It rereads the whole context. And so weighted by cost, this bill scales pretty steeply and you can end up in a situation where it should have really only verified a few times and it didn't and it went into a bit of a tail spin and now it's 3x the cost.

11:06 It's a really big question for us. Who's filling that bill? Right. so measurement so so we're very eval first at lovable and we consistently measure a lot of models on a lot of different capabilities in our harness in particular and we really want to be measuring the divergence between appetite for verification and demand. So, it's that divergence we care about. or we're happy with 50 screenshots being taken if a user has really deemed it super necessary for that to happen. I I'd be hardressed to find that as a production trace, but never say never. So, really like the things we're judging, we're judging outcome. We want the request to be fulfilled. We do not want abandonment of the request. there's a lot of moving parts in our harness and we still need to make sure the outcome is completely up to par. We want the slice of traffic that belongs with sort of that thrashes to be judged on bounding verification. So understanding what is the minimum amount of interaction with the browser that you really needed for this to happen. Ideal case scenario we wouldn't need to verify because it would just be glory days and every change it makes is perfect and correct. But that's not the reality. and the slice of traffic where we see huge underverification from certain models.

12:28 We want to make sure that where verification is warranted, it actually happens. and certain ways we can also measure this deterministically not through judges are basically tool thrashing. So when you have sort of bite a bite level loop detector and you can really understand that certain scripts are just being rerun and rerun with very very very minor changes. and also a token budget and but those are two more sort of like crude huristics here. So where models sit today this is from an eval that we have. you can see that essentially the top left corner shows a very large appetite for over verification or thrashing and it like models that would sit in the top left show very little appetite for underverification. And conversely, the bottom right shows a large appetite for underverification and not a very small appetite, basically very little over verification or thrashing. so ideally a model would sit in the top right. That means demand and appetite are met. it verifies more often when it should and less often when it shouldn't. but you already start to see a bit of a difference in model families here. So families sitting on this X intercept that you can kind of actually almost draw a straight line down from soul to Luna for GPT they show like a fixed appetite for over verification and that appetite for underverification goes away basically as you rise up. So Soul is less likely to not verify essentially than Luna. and you can see that Luna over there in the bottom right basically the majority of the time in the exact same harness will verify way less often just not check work essentially. so yeah, you can see that the size of the marker is essentially weighted tokens represented tokens weighted by cost. so we have two open source models that are sort of much more token heavy and as a result like eat that eats up a large share of the bill. So from the previous graph you may sort of jump to the conclusion that perhaps soul looks like a bit of a winner there in the top right. but actually when you look at outcome so now we're really looking at previously we were looking at just whether or not it is oververifying or underverifying. I actually really still need to know did the job get done well. and when you look at outcome there are two distinct way ways to fail here. All of these bars show failure. none of them are particularly good. It's about the difference in those two bars. So one family really thrashes. but the outcome judge is pretty much always satisfied with the execution and that's where the orange bar is very high. And the other family basically normally tends to underverify and as a result the outcome suffers and it's deemed not like to do as well basically which is the right hand side which is family of GPT models mainly and that's like a very interesting behavior to me. it makes a lot of sense in my mind when I look at the token efficiency of GPT models. thrashing is is is is rarely possible in a in a in a particularly token efficient model by definition. and underverification is more likely in a token efficient model.

16:02 so yeah, neither is free. One costs tokens which is more verification but a slightly better outcome and the other really costs trust with our users. So what's also interesting to see is this is fable 5.1 but this scales quite dramatically in all senses with effort level. and this is something we see across the board for models that essentially overification really starts to set in as effort levels increase. so this is something we have to consider when we run our models in our harness. we might not be able to afford the luxury of overifying not just from a cost perspective but also from a waste perspective and a latency perspective. and you can see that obviously the same happens with tokens as effort scales it increases. So yeah, what actually helps this in practice? the bad news is we tried quite a bit of quite a quite a few things. we did a lot of automated prompt search with things like Japa because the first thing you kind of look at is the context window. What is in there with every single request? I want to look at the exact JSON payload and understand is there anything in here that might be encouraging this. and actually that yielded little movement.

17:27 it created edge cases. We had small regressions and we had very different signs on different models. And we actually looked at removing anything. We wanted to understand like if you have these CLIs and these libraries available in your execution environment, what do you actually do? If we don't tell you to do anything, if we don't tell you to verify and we say don't verify too much, and sorry, and we don't say don't verify too much, then what do you reach for? What is your behavior? Sort of like what is your nent behavior? And it very much shifted token spend with respect to verification but it shifted it from browser use to other forms in families like claude. So that could be type checking, it could be interaction with specific logs. so this this this sort of correlated quite strongly with like a sense of anxiety. and it very much hurt warranted verification. You can imagine it basically just underverified a lot of the time. and for scriptbased tooling, we tried to sort of look at loop detection. Like I said earlier, it's actually quite hard.

18:33 I think ask anyone who looks at a lot of observability of shell commands and it's pretty hard to know when an agent's doing the exact same thing because there's many many ways to do one thing in bash. So understanding how exactly it's detecting things or understanding exactly what it's doing in the browser and whether or not that's identical isn't just a question of saying like are the tool call arguments identical in both cases. So an interesting thing that we also did with respect to prompting is we took a method from a paper called context site and we actually look at looked at like ablating the context window with respect to if I remove this piece of the context window how does it affect the trajectory? Does it is there something in here that is essentially really scoring highly with respect to starting a thrash or like providing that initial like inertia? and essentially we found that the decision to reverify consistently or thrash rides about 70% on the agent's own actions. So something that we don't actually have static control over before we send the inference request necessarily. I mean we could sort of take out some of its previous actions but then that begs the question which ones and a large majority of this was actually its own reasoning tokens. So when it decided in its own reasoning to essentially start to verify there was not much by way of like scoring with these lasso systems that indicated there was something in the context window giving a sort of an effect that would dep prioritize that or like push that off the trajectory it's on. so the portion of the system prompt that talks in any way about verification really didn't affect it that much in ablation studies and the user's message was sort of under 3% score-wise. which is quite damning if you think about this as like a a sort of weights versus harness problem. so what really helped move the needle budgets not sentences. So this wasn't so much a prompting issue in a system prompt sort of way. what did really help is stage windowns. So essentially like midsystem reminders to warn stop and terminate based on time iteration token counts and repeated calls.

21:03 this actually helped it moved our like cost per turn down by several percent. That's over all our traffic. So you can imagine that's like quite a good thing for us and our users. choosing the right tool is incredibly important. you know a screenshot really might not be the best way to investigate a difficult runtime error. it might have an effect but like really choosing the right tool is important. so things like diff in the DOM versus screenshots. things like delivering the appropriate error messages as logs GP and curl versus always you know sort of splashing the context window with image to like image tokens consistently. And this was sort of the last thing which is half of the real defects we saw are where agents are really trying to sort of circumn.

22:05 this is particularly hard for us. We are running local browsers. we have users with thousands of users of their lovable app. our agent needs to go and help build features, make sure it doesn't break anything. and then go into the browser and basically test things. And this is particularly difficult. You can imagine a lovable user sort of receiving a request to impersonate one of their end users swiftly declined because that's not necessarily a good idea. And we had to come up with good ways of minting sessions to the agent for different users or test accounts that also wouldn't create sweeping regressions in their cloud services. Right? And this is all the things we manage and we can't make any assumptions about our users being particularly fluent in what it means to have a dev pod split or what it means to have RLS and things like this. things need to work very seamlessly without much information being provided from the user and that includes essentially our harness or our agent understanding when it needs to verify and when it shouldn't.

23:25 so yeah, thank you very much.

Summary

Vic Klein discusses the role of browser interactions in Lovable's coding agent, emphasizing the importance of verification in ensuring user trust and efficient operations. He outlines the challenges of balancing verification demands with the costs associated with over and under verification, particularly in a high-volume production environment.

- Lovable builds full-stack applications and relies heavily on browser interactions for its coding agent.
- Verification encompasses visual checks, measuring DOM layouts, and debugging, which are crucial for user trust, especially for non-technical users.
- The agent experiences significant traffic, with 2.4 million turns daily, where about 20% involve browser interactions, leading to high token costs.
- Over verification (thrashing) and under verification both pose risks, with the former leading to unnecessary costs and the latter risking user trust.
- Effective measurement of verification appetite versus demand is essential to optimize performance and reduce costs.
- The choice of tools and methods for verification (e.g., screenshots vs. DOM diffs) significantly impacts efficiency.
- Strategies like mid-system reminders and careful management of context windows have proven effective in reducing costs associated with verification.
- The challenge of managing user sessions and ensuring seamless operation without requiring technical fluency from users is critical for Lovable's success.

Questions Answered

What is the role of browsers in Lovable's coding agent?

Vic Klein introduces the concept of browser interactions within Lovable's coding agent, emphasizing the importance of verification in the development of full-stack applications.

Why is verification critical for user trust in applications?

Verification is essential to maintain user trust, especially for non-technical users. The agent must balance the appetite for verification with the demand for it to avoid over- or under-verification.

How does verification impact operational costs?

Verification processes can lead to significant costs due to token usage, especially when unnecessary interactions occur. Efficient management of these processes is crucial to avoid excessive spending.

How do different models perform in terms of verification?

Different models exhibit varying tendencies towards over- and under-verification, impacting their overall effectiveness. The performance of these models can be assessed by their ability to complete tasks satisfactorily.

What factors influence an agent's decision to verify?

The agent's own actions significantly influence its verification decisions, with a majority of verification behavior driven by its internal reasoning rather than external prompts.

© transcribe · For agents Built with care and craft by Gokul Rajaram