Skip to content
Phạm Nam

Search

Type a keyword to search the posts.

Go back
en

agent-browser: Let AI Agents Drive a Real Browser

agent-browser from Vercel Labs lets Claude Code open a real browser, read snapshots, click by ref, and verify UI fixes — install it in two commands today.

10 min read—

An AI agent driving a real browser with agent-browser: opening a page, reading a snapshot, clicking by ref, and verifying the result

What Is agent-browser? A CLI That Lets AI Agents Drive the Browser

You asked Claude Code to fix the login page. The agent reports it is done, the diff looks fine, the build passes. You open the browser, click Sign in — and the form does nothing. A JavaScript error sits in the console that the agent never saw, because it has no browser. So you become the agent’s “eyes” again: screenshots, console errors, pasted into chat.

agent-browser from Vercel Labs fills exactly that gap: a CLI the agent calls one shell command at a time to open a page, read a snapshot, click by ref, fill a form, and read console errors.

What Is agent-browser?

agent-browser is an open-source command-line tool written in Rust (Apache-2.0) from Vercel Labs, in the repository vercel-labs/agent-browser, with documentation at agent-browser.dev — the project’s slogan is “Browser automation for AI agents”.

It works very directly: the agent runs agent-browser open example.com, then agent-browser snapshot -i to see the interactive elements, then agent-browser click @e1 to click one of them, then snapshots again to verify the result.

The repo was created on 11/01/2026; by 14/11/2026 it had 50,739 stars and 3,526 forks on GitHub, with the latest release v0.43.0 published on 12/11/2026, just two days after v0.42.0.

The Problem It Solves

A coding agent lacks a pair of eyes: it writes code, runs builds, runs tests — but it cannot open a browser itself to see what it just built actually looks like. The fix-and-check loop therefore always breaks at the final step. Playwright or Puppeteer demand writing code and holding a long-lived process; an agent just wants to run one command, read the result, and decide the next one.

Who Should Use It, and Who Does Not Need It Yet

Use it if you use Claude Code, Codex, OpenCode, or Gemini CLI and are tired of hand-checking every UI change; if you work in DevOps/SRE and want an agent to check the web UI itself after every deploy; or if you do QA and want an agent to run a login flow, fill a form, and test a checkout on its own.

You do not need it if the job is only fetching static HTML — a lightweight scraper such as Scrapling is enough and much faster. You also do not need it if you only need a super-light headless engine embedded in code — then use Lightpanda directly, the very engine agent-browser can drive.

Architecture and How It Works

The Core Loop: Snapshot → Ref → Action → Verify Again

agent-browser open example.com   # 1. Open the page
agent-browser snapshot -i        # 2. See the interactive elements
agent-browser click @e1          # 3. Act by ref
agent-browser snapshot -i        # 4. Snapshot again to verify the result

snapshot does not return the raw DOM; it returns the page’s accessibility tree — a semantic summary of headings, textboxes, buttons, and links — each element carrying a ref such as @e1, @e2. The agent reads this tree with far fewer tokens than a full DOM dump.

A ref is a temporary handle, tied to one specific snapshot of the DOM. After navigation or a DOM change, an old ref may no longer be valid — take a fresh snapshot before acting again. That is the most important operating rule when using agent-browser. Because the snapshot uses the accessibility tree, it cannot see layout or images — screenshot, diff, vitals, and console are mandatory complementary channels, not side features.

Components: CLI, Daemon, Browser, CDP

flowchart TD
    A["AI Agent"] --> B["agent-browser CLI"]
    B --> C["Daemon per --session<br/>holds session state"]
    C --> D["Browser via CDP"]
    D --> E["Real web page"]
    C --> F["Optional engine<br/>Lightpanda / Obscura"]
    C --> G["Cloud provider"]
    C --> H["Mobile Safari<br/>in iOS Simulator"]
    E --> I["Snapshot: accessibility tree + refs @e1"]
    I --> A
    A --> J["click / fill / type @e1 → snapshot again"]
    J --> E
    D --> K["Click fails when target is covered → handle it, snapshot again"]
    B --> L["Auth vault + allowlist + confirm/deny"]
    L --> C

The core design is “stateless CLI on a stateful daemon”: each command is a short request to a background daemon, started on the first command, which holds the browser via the Chrome DevTools Protocol (CDP). Each --session has its own daemon and browser, so state, cookies, and credentials do not leak into another session. The daemon closes the headless browser automatically after 1 hour with no commands.

By default it uses Chrome for Testing (downloaded via install); attach to an already-running Chrome with --cdp or --auto-connect; for a lighter engine choose --engine lightpanda or --engine obscura; Mobile Safari in the iOS Simulator and cloud providers are also available.

Connecting to Claude Code: Skills and MCP Server

There are two ways to connect agent-browser to your agent. The first is a skill: run agent-browser skills get core for the main loop instructions, or add this to AGENTS.md:

Use `agent-browser` for browser automation. Before the first use, run `agent-browser skills get core` and follow it.

The second is an MCP server: run agent-browser mcp to start an MCP server over stdio — use it when the agent has no shell, or when you want browser actions to go through structured tool calls.

Version v0.43.0 just added snapshot hints — extra information for controls with no accessible name — and the Modern Web Guidance skill, which checks whether a page was built following Chrome’s guidance (see Modern Web Guidance 1.0). Version v0.42.0 added saved flows (experimental).

Limits to Know Before Using It

A click reports an error instead of a false success when the target is hidden, disabled, outside the viewport, or covered — for example by a consent banner. That is the correct design: handle the covering element, snapshot again, and click again. SPAs that change the DOM constantly are the hard case: refs expire quickly, so the agent must take a fresh snapshot before every action. Each step is a shell call through the daemon and CDP, so it is slower than a Playwright script holding a continuous connection.

Installation and Your First Workflow

This article was verified against agent-browser v0.43.0 (12/11/2026), Linux x86_64. Installing via npm requires Node and npm; on Linux you also need system libraries.

npm install -g agent-browser
agent-browser install          # downloads Chrome for Testing the first time

On macOS: brew install agent-browser, then agent-browser install. On Linux, if the browser fails to start because system libraries are missing: agent-browser install --with-deps. If you do not want to install it, run it directly: npx agent-browser open example.com.

I installed and ran it for real while writing this article: agent-browser install downloaded Chrome 157.0.8103.78 (194 MB) in about 10 seconds, and agent-browser --version returned agent-browser 0.43.0. The doctor command checks the environment and reports each item clearly.

First Workflow: Open a Page, Snapshot, Click, Verify

I ran the sample workflow on a local HTML page with a login form (the writing machine’s proxy blocked navigation to external sites — see the verification scope at the end of this article):

agent-browser open file:///tmp/test-page.html
# ✓ Trang test agent-browser
#   file:///tmp/test-page.html

agent-browser snapshot -i
# - heading "Đăng nhập demo" [level=1, ref=e2]
# - textbox "Email" [ref=e5]
# - textbox "Mật khẩu" [ref=e6]
# - button "Đăng nhập" [ref=e3]
# - link "Tìm hiểu thêm" [ref=e4]

agent-browser click @e3
# ✓ Done

agent-browser snapshot
# ...
# - StaticText "Đã bấm Đăng nhập — form đã chặn submit thật."

agent-browser console
# (empty — no console errors)

agent-browser close
# ✓ Browser closed

Note: the snapshot returns refs in the form ref=e3, but when you call a command you write @e3. After the click, the fresh snapshot showed text the page’s JavaScript had just written into the DOM — the agent could verify the result of its own action from the snapshot itself. With a real form, add fill or type on the textboxes before clicking submit, and use console or errors to read errors.

Common Errors and How to Handle Them

  • Click reports an error because the target is covered, hidden, disabled, or outside the viewport. This is the tool’s correct behaviour. Handle the covering element, snapshot again, then click with the new ref.
  • Ref expired after navigation or a DOM change. Take a fresh snapshot before every action.
  • Sessions leaking into each other between tasks. Use a separate --session for each task — the default session is a browser shared with every other agent on the machine. Close it with close when done.

Technical Assessment

Strengths. Any agent that can run a shell can drive a browser — no SDK, no automation code. The compact accessibility-tree snapshot saves agent context versus a DOM dump, and snapshotting again after every action greatly reduces “false success”. confirm/deny, a domain allowlist, an action policy, and an auth vault are built in.

Weaknesses. Each step costs a shell call through the daemon and CDP, so it is slower than a Playwright script holding a continuous connection. The snapshot depends on the accessibility tree: heavily custom sites, canvas, CAPTCHA, or bot detection can leave it incomplete or block it entirely. The project is at v0.4x, so its API and behaviour change quickly between releases.

Security. The docs list an auth vault, domain allowlist, action policy, and content boundary — deeper details live in docs/security, which I have not read in full. Safe practice: allowlist only the domains you really need; use a separate session for sensitive tasks; enable confirm for sensitive actions; revoke vault credentials and delete the session when done. Compared with HeldKeys: HeldKeys checks what an agent can access; agent-browser controls what an agent may do on the web.

Performance, scaling, operations. Verified: v0.43.0 speeds up snapshots of large pages; each session has its own daemon and browser; cloud providers exist for running off the local machine. Realistic scaling is parallel runs with multiple --session flags — limited by each browser instance’s RAM/CPU and the target site’s rate limits, to be measured on a real workload. Update with agent-browser upgrade; because releases are frequent, pin the version in CI or important workflows instead of latest. Rollback is simple, since the tool never modifies your source code: remove the CLI, remove the skill from AGENTS.md, delete saved sessions and state, and revoke vault credentials.

Comparison With Alternatives in the Same Space

Criterionagent-browserPlaywright / PuppeteerLightpanda (direct)Scraper (e.g. Scrapling)
AudienceAgent calling shellDeveloper writing codeDeveloper writing codeDeveloper writing code
ControlShell commands + snapshot/refAPI/SDK, long-lived processCDP from codeHTTP + parse HTML
EngineChrome for Testing / Lightpanda / Obscura / cloudChromium/Firefox/WebKitZig headless engineNo browser needed
Best caseAgent checks UI/forms itselfTests and automation written in codeLightweight engine embedded in a systemStatic HTML only

Playwright and Puppeteer are stronger for tests and automation written in code; agent-browser wins on “the agent just calls it and it runs”, with the lowest integration cost. Lightpanda is a headless engine written in Zig — a different layer, which agent-browser can use as an engine via --engine lightpanda.

Real-World Use Cases

  • DevOps/SRE after a deploy: the agent opens the production or staging page itself, snapshots the key components, and reads console and errors.
  • QA/automation: the agent runs a login flow → fills a form → test checkout, verifying each step with a snapshot.
  • Developers and AI workflows: Claude Code fixes a UI, then opens the page itself to check it, reads the errors, and keeps fixing without anyone taking screenshots. When many agents run in parallel — for example with Orca or Agent Autoloop — each agent uses its own --session.
  • Homelab, IT admins, and businesses: the agent checks a self-hosted dashboard after a config change, or runs a post-release smoke check on staging — locally with Chrome for Testing or Lightpanda.

Conclusion

agent-browser fits teams already using a coding agent and tired of being the agent’s “eyes”, and anyone who wants to integrate it in a few minutes via a skill or MCP. It does not fit if you only need to scrape static HTML, if you need a super-light engine embedded in code, or if the target site blocks automation aggressively.

Three next steps: npm install -g agent-browser && agent-browser install; run the sample workflow — open → snapshot → click → close — on one of your own pages; add the skill to AGENTS.md or run agent-browser mcp.

Lessons Learned

  1. Snapshot and ref are the working contract with the agent — a stale ref after a DOM change is the most common cause of a wrong click.
  2. A click reporting an error is a feature, not a bug — handle the covering element, then snapshot again.
  3. Choose the engine for the need: Chrome for Testing by default for the highest compatibility, Lightpanda when you need it light.
  4. Control before autonomy: set the allowlist and confirm before letting the agent run on the real web.
  5. Pin the version because releases are frequent — today’s workflow may change within weeks.

Verification Scope

Checked on 14/11/2026 against the README, CHANGELOG, and GitHub API of vercel-labs/agent-browser: star/fork counts, the v0.43.0 release date, install commands, quick start, the daemon and CDP mechanism, the skill and MCP server. I installed and ran agent-browser 0.43.0 for real while writing this article: agent-browser install downloaded Chrome 157.0.8103.78 (194 MB), and the open → snapshot → click → verify snapshot loop ran on a local HTML page. Navigation to external sites did not run here because the machine’s proxy blocked Chrome’s connection (ERR_TUNNEL_CONNECTION_FAILED) — a limit of the environment, not of the tool. Star counts are written as “more than 50,000” because they change daily. There is no independent benchmark; all statements about speed are analysis, not measurements.

References


Related posts

Bình luận

Bình luận được duyệt trước khi hiển thị.

Đang tải bình luận…

Để lại bình luận