Browser automation

What Is Agent Browser and How Does It Work?

Agent Browser is Vercel Labs’ command-line tool for browser automation. Learn how an AI agent reads a page, chooses an element, and checks what a click did.

By CloudbrowserPublished

Where Agent Browser fits

Say you ask a coding agent to check whether a new search box works. The agent needs to open the site, find the search field, enter a query, and inspect the results. Vercel Labs’ agent-browser gives it shell commands for each of those actions. Chrome loads the site and runs its JavaScript. The agent interprets what comes back and decides what to do next.

The phrase “agent browser” can also describe a browser that lets an AI act on your behalf. In the Vercel Labs project, the name refers to the automation tool. A developer can issue its commands directly, and an AI agent with shell access can issue those same commands.

How does an agent know where to click?

People can recognize a search box from its position and appearance. Agent Browser can describe it using the page’s accessibility information, including its role and name. Running agent-browser snapshot -i asks for interactive elements. A snapshot of a catalog page might contain these two lines.

- textbox "Search the catalog" [ref=e1]
- button "Search" [ref=e2]

The references give the agent a short way to address each element. Here the first command enters a search term and the second submits it.

agent-browser fill @e1 "rain jacket"
agent-browser click @e2
agent-browser snapshot

The final snapshot matters as much as the click. A results heading, a “no matches” message, and a validation error all call for different next steps. References belong to the page the agent inspected, so it should take a fresh snapshot when the page changes. If a custom control has no meaningful label, a screenshot can help the agent inspect what is visible.

When is browser automation useful?

A useful test for the search box is whether a shopper can find a specific jacket by name. A direct API request can tell you the catalog contains it. Driving the browser also exercises the field, the submit action, and the results the shopper actually sees.

Another example is entering a few supplier records into a portal that only exposes a web form. The agent can identify fields by their labels and fill one record for a person to review. After submission, a confirmation number gives the workflow something concrete to verify. For larger batches, a supported import or API can avoid repeated navigation. The form-filling guide walks through the review and confirmation steps.

Where does the browser run?

For a local test, the CLI can launch Chrome on the machine running the commands. It can also attach to Chrome that is already running elsewhere. CDP, short for Chrome DevTools Protocol, is one way it makes that connection. In agent-browser --cdp "$CDP_URL" snapshot, the URL identifies the browser whose page the agent will inspect. See the official CDP reference.

The location matters when a task depends on a login. If you sign in to a site in a remote Chrome desktop and attach the CLI to that same browser, the agent can work with the session you prepared. The website still controls when that login expires. A persistent browser profile can keep saved cookies between tasks, while separate browsers give concurrent tasks independent tabs and profiles.