Agents & AI
Browser agents: Accessibility Tree vs screenshots, how many tokens do you really save?
Measured on a 10-step task: the Accessibility Tree filtered to what's visible uses 85% fewer tokens than screenshots. Filtering the whole page can cost more than a screenshot.
- Date
- Oct 19, 2026
- Reading time
- 8 min
- Result
- 1,991 tokens with the visible tree vs 13,650 with screenshots • 85.4% fewer • 80 of 80 clicks by reference
Translated from the Spanish original. The code, data and READMEs on GitHub are in Spanish.
Giving a browser agent the Accessibility Tree filtered to what’s visible on screen, with [ref=eN] references, uses 85.4% fewer tokens than sending it a screenshot at every step: 1,991 tokens vs 13,650 on a 10-step task (Claude’s formula). Clicks by reference hit 80 out of 80. But beware: if you filter the whole page instead of what’s visible, on a website with lots of links the tree can end up more expensive than the screenshot.
Measured on 19 October 2026 on a MacBook Pro M1 Max with Playwright and Chromium, on a real 10-step task on this very website served locally.
Definitions
- Browser agent: a language model that drives a browser step by step: it looks at the page, decides and clicks or types.
- Observation: what the agent receives at each step to “see” the page.
- Accessibility Tree: the structure the browser builds for screen readers: roles (link, button, field), names and states. It’s not pixels: it’s text.
- Reference (
[ref=eN]): an identifier the agent uses to say “click e7” instead of giving (x, y) coordinates.
Hypotheses
- The Accessibility Tree uses far fewer tokens than screenshots.
- Clicking by reference doesn’t fail.
- Getting the tree is faster than taking a screenshot.
Setup
- A 10-step task on yeswelab.com: open the home page, go to Experiments, search for “tokens”, open an experiment, scroll to the end, go to Guides, open a guide, go to the form, type the hypothesis and tick an option.
- At each step, four observations: a 1280×800 screenshot (at 1x and at 2x, like a Retina screen), the full tree, the filtered tree (only interactive elements and headings, with references) and the filtered tree limited to what’s visible.
- Image tokens: with the formula published by Anthropic for Claude and by OpenAI for GPT-4o in high detail. Text tokens: the
o200k_basetokenizer (GPT-4o/GPT-5). - Clicks: the simulated agent clicks the centre of the element its reference points to, and we check that the point lands on that element or its label.
- 5 repetitions of the full task for each screen scale.
Results
Tokens for the full task (10 steps)
| Observation | That step’s observation only | With full history |
|---|---|---|
| 1x screenshot, Claude’s formula | 13,650 | 75,075 |
| 2x screenshot (Retina), Claude’s formula | 15,330 | 84,315 |
| Screenshot, GPT-4o’s formula | 11,050 | 60,775 |
| Full tree, with text | 67,340 | 378,509 |
| Filtered tree, whole page | 16,447 | 95,560 |
| Filtered tree, visible only | 1,991 | 10,369 |
“With full history” is an agent that resends all previous observations at every step, which is common if context isn’t managed.
Per step (median)
| Observation | Tokens per step |
|---|---|
| 1x screenshot (Claude) | 1,365 |
| Full tree | 6,457.5 |
| Filtered tree, whole page | 1,958 |
| Filtered tree, visible only | 203 |
Speed and clicks
| Measure | 1x screenshot | 2x screenshot | Filtered tree |
|---|---|---|---|
| Capture time (median) | 53.45 ms | 154.35 ms | 36.69 ms |
| Successful clicks by reference | — | — | 80 of 80 |
What it means
- Hypothesis 1 only holds if you filter properly. The tree limited to what’s visible uses 85.4% fewer tokens than the screenshot (87% fewer than the Retina screenshot and 82% fewer than GPT-4o). But the filtered tree of the whole page used more than the screenshot: 20.5% more with Claude’s formula and almost half again (48.8%) more than with GPT-4o. On long pages with lots of links, such as a listing or a blog, filtering by element type isn’t enough: you have to trim it to what’s visible.
- The full tree is the worst option: almost 5 times more tokens than screenshots. Sending the model all the page’s text is expensive and unnecessary for navigation.
- History multiplies the cost. Resending all 10 screenshots at every step goes from 13,650 to 75,075 tokens. With the visible tree, from 1,991 to 10,369. Trimming history matters as much as choosing the observation; we saw it in context engineering.
- Clicking by reference didn’t fail once in 80 clicks: the agent doesn’t have to guess coordinates.
- Getting the tree takes 36.69 ms per step, less than a screenshot, and doesn’t depend on screen resolution.
When to use each option
- Filtered, visible tree with references: by default, for forms, navigation and repetitive tasks on well-built websites.
- Screenshot: when what matters is visual (a chart, a map, a canvas, an embedded PDF) or the website has poor accessibility. Better as an occasional complement than at every step.
- Full tree: almost never for navigation; only to extract the text of a specific page.
What we said on X and what we measured
In the X thread we gave early figures from a run of our agent on other pages and with another configuration: 166,000 tokens with screenshots vs 3,000 with the filtered tree (−97%). Here we measured it reproducibly, with the code published: the direction is confirmed, but the figure depends a lot on the website, the resolution, the model and whether the agent resends its history. On this task, the reduction was 85.4% and, with full history, 86.2%. That getting the tree takes under 0.8 s per step and that clicks by reference don’t fail is confirmed.
Limitations
- A single website, ours, locally, with one specific task. Websites with poor accessibility (unnamed buttons, everything on a canvas) would produce worse trees.
- Claude’s tokens are approximated: its text tokenizer isn’t public; text is counted with
o200k_base. Images are calculated with the published formulas, not with real billing, and more recent models may count them differently. - There’s no real model making decisions. We measure the observations and the reliability of clicking by reference, not a full agent’s success rate or the model’s latency.
- The visible tree requires scrolling to reach off-screen elements: it saves tokens per step but may add steps.
- Timings from a single laptop with other applications open: good for the order of magnitude.
How to reproduce it
Code, environment and raw results, step by step and repetition by repetition: yeswelab-laboratorio/agentes-navegador-accessibility-tree-vs-screenshots-tokens on GitHub. It works with any static website by changing the task’s steps.
Related
- AI agent harnesses: OpenClaw, Hermes Agent, Claude Code, Codex and goose
- Mortadelo: a Hermes agent running the lab 24/7
- How many more tokens does Spanish use than English?
Planning to have an agent drive the browser in your company? We measure cost, reliability and risks on your real websites. Commission the experiment.