Where a Browser Agent's Tokens Go, and How to Cut Them

6 min read

A browser agent that works but takes ten minutes and a dollar per task is hard to ship. Speed and cost come from the same place: how many model requests a task needs, and how big each request is. This part measures where the tokens go, using real logs, and walks through the levers browser-use 1.0.9 gives you.

Hand-drawn diagram: the system prompt and tool schema are sent with every request, history grows every step, and screenshots add to it when vision is on. Compaction at 75% of max_context_chars summarises history, a prompt cache reuses the unchanged prefix on Claude routes, and ultrafast mode keeps cells small with bu.state text. Measured: prompt tokens per request went from 1,917 to 4,282 over 11 requests with gpt-oss-120b

Problem: the prompt grows every step

Each step sends the system prompt, the task and the whole history so far. So request 10 carries everything from requests 1 to 9. Total input tokens grow roughly with the square of the step count.

Here is what that looked like in our real-model runs (Part 4). A local adapter logged every request's prompt size. These two runs had no screenshots, because the adapter dropped images:

Prompt tokens per request (real runs, no images)
4518.53099.51680.5191712158222873251642770529586321373849840669415010428211
Data from the sources listed below.

That is gpt-oss-120b. gpt-oss-20b, on the same task, went from 1,845 to 2,359 tokens over 7 requests. The first request alone, about 1,850 to 1,950 tokens, is the fixed cost: system prompt, tool schema and task.

RunRequestsInput tokensOutput tokensInput share
gpt-oss-20b714,74369396%
gpt-oss-120b1134,1661,24396%

Input dominates. Output is short because each step is one cell. So cutting input is where the money is.

flowchart LR
  S[System prompt + tool schema, fixed] --> R1[Request 1]
  S --> R2[Request 2]
  S --> R3[Request N]
  H1[History after step 1] --> R2
  H1 --> R3
  H2[History after steps 2 to N-1] --> R3
  R3 --> X[Input tokens grow each request]

Lever 1: fewer steps through code

The biggest saving is not making a request at all. One cell that loops over a table in Python replaces dozens of click-and-read steps. The launch post gives an example: an agent pulled 4,720 rows of stock data in 3.5 minutes by finding a JSONP endpoint and calling it from code, instead of paging through a UI.

Our scripted Hacker News run (Part 4) read five titles in one cell. The whole run was 4 steps, including delivery.

Lever 2: deliver from the REPL, not from the model

finish_from_repl(expression='json.dumps(rows)') hands back the value of a REPL variable. The model does not retype the data as output tokens. For a 1,000-row result that is the difference between a few tokens and many thousands.

Lever 3: compaction

browser-use 1.0 compacts old history. In agent/loop.py, compaction triggers when the history passes 75% of max_context_chars, or 65% of the model's context window in tokens:

python
return chars > 0.75 * max_chars or bool(window and tokens > 0.65 * window)

That line is quoted from the 1.0.9 source. The migration guide describes the same 75% rule. Compaction trades detail for size: old cells become a summary, so the model may forget a precise value it saw early on. That is another reason to keep important data in REPL variables or checkpoints, not only in the transcript.

Lever 4: prompt caching

Most providers can cache an unchanged prompt prefix and bill it at a discount. The system prompt and the early history are exactly that kind of prefix. browser-use has a _wants_cache check in loop.py. Its docstring says Claude caches nothing unless asked, on every route, so the loop adds cache breakpoints for Claude models.

Release 1.0.9 fixed a bug here. Before it, Claude prompt caching on OpenRouter and Bedrock was not working and cache_read was always 0. If you ran 1.0.0 to 1.0.8 on those routes, you paid full price for every prefix.

You can check this yourself: result.usage reports cache_read and cache_write. In our Workers AI runs both were 0, which is expected for that route.

Lever 5: smaller views and smaller models

  • Ultrafast mode (mode='ultrafast') gives the model bu.state(), a compact text view capped at 3,000 characters by default (Part 3), and short id-based actions.
  • Vision off (use_vision=False) keeps screenshots out of the prompt entirely. It saves tokens but loses layout and overlays.
  • Smaller models. The migration guide lists Browser Use's gateway prices: bu-4.0 at $1.80 per million input tokens and $9.00 per million output, and bu-fast at $0.12 and $0.60.
Gateway price, US dollars per 1M input tokens
bu-4.01.8bu-fast0.1
Data from the sources listed below.

As a rough illustration, our gpt-oss-120b run used 34,166 input and 1,243 output tokens. At the bu-4.0 prices above that would be about $0.061 for input plus $0.011 for output, so about $0.07. At bu-fast prices it would be about $0.005. That is arithmetic on our token counts, not a measured bill, and a different model would take a different number of steps.

What the team measured

The 1.0.0 release notes report BU Bench v2 results (60 tasks, 3 runs each, November 9, 2026), with gpt-6-luna as the agent model and gpt-5.6-luna as the judge:

AgentScoreCost per taskTime per task
browser-use 1.0, ultrafast62.5 (CI 58.3 to 66.5)$0.070650 s
Browser Use Pi56.3$0.082743 s

The notes say the paired difference was +1.1 and not statistically significant. So on that benchmark, ultrafast mode matched their previous agent at somewhat lower cost and time. The launch post's broader claim, 2.7 to 5.2 times cheaper and 2 to 3 times faster than the 0.x agent, is from one run per model.

The Online-Mind2Web post adds one formatting trick: sending tables as TSV instead of JSON saved 40% of tokens in their setup.

What cost_usd does and does not include

result.cost_usd is computed when the model's price is known, and is None otherwise. The migration guide says it covers model and web search charges, not the cloud browser or proxy. The README lists cloud browsers at $0.06 per browser-hour. So for cloud runs, add browser time to the model bill.

flowchart LR
  A[Task] --> B{How many steps?}
  B -->|code loops, finish_from_repl| C[Fewer requests]
  B -->|one click per step| D[Many requests]
  C --> E{How big is each request?}
  D --> E
  E -->|compaction, cache, ultrafast, vision off| F[Smaller prompts]
  E -->|full history, screenshots| G[Large prompts]
  F --> H[Lower cost and latency]

Speed: where the seconds go

Wall time per step is mostly model latency. In our scripted runs, where the "model" answers instantly, a 4-step Hacker News run took 4 to 6 seconds of loop time, most of it page loads. The real gpt-oss runs took 53.8 and 58.7 seconds for 7 and 11 requests. So the browser side was a small part. Faster models and fewer steps matter far more than CDP latency (Part 6).

Try this

Run the same task twice with use_vision=True and use_vision=False, and compare result.usage['input']. Then compare result.success. That is your price for sight on that task.

Sources