AI Agents That Use a Browser: Playwright, Vision and Tooling Choices

AI browser agents open pages, read them and click through tasks using Playwright. This guide compares the tooling choices and the safety rules that matter.

By Galactic News Editorial · Published 2026-11-21T01:36:03+00:00 · Updated 2026-11-21T01:36:03+00:00

AI browser agents that use a browser with Playwright

AI Agents That Use a Browser: Playwright, Vision and Tooling Choices

AI browser agents open web pages, read them, and click through tasks on their own. They fill forms, check prices, run tests, and gather research. The agent decides what to do next by looking at the page. Playwright is the most common tool behind them. This guide covers how these agents work, the main tooling choices, and the safety rules that keep them from doing damage.

How AI browser agents work

A browser agent runs an observe-act-verify loop. It inspects the page, takes an action, and checks the result. Then it repeats. Microsoft’s Foundry documentation describes the loop clearly: receive a task, create a browser session, observe and act, verify the page state, then finish and close the session.

The agent needs two things to work. First, a way to see the page. That is usually an accessibility snapshot: a structured tree of headings, buttons, links, and form fields. Second, a way to act: navigate, click, type, select, and run JavaScript. The model reads the snapshot, picks an action, and the browser executes it.

Vision is the alternative to snapshots. The agent takes a screenshot and reasons about pixels. Vision handles pages where the accessibility tree is thin, such as canvas apps and complex widgets. Snapshots are cheaper, faster, and more precise for standard pages. Most production agents use snapshots first and fall back to vision when the tree is not enough.

AI browser agents: the main tooling choices

Four approaches cover most projects. Pick based on where the browser runs and how much control you need.

Playwright MCP server, local. The Playwright MCP server gives an AI coding assistant direct access to a live browser session. Install it with npm install -g @playwright/mcp, or run it without installing via npx @playwright/mcp. It needs Node.js 18 or later and a Chromium-compatible browser installed through npx playwright install chromium. The server exposes tools such as browser_navigate, browser_snapshot, and browser_click. The assistant inspects the real DOM, clicks elements, and observes navigation. It then generates precise Playwright tests from what it finds. This is the best choice for test authoring and local development.

Playwright Workspaces remote MCP server, managed. Microsoft’s Playwright Workspaces offers a remote MCP server that connects an agent to a managed cloud browser. You do not install Playwright or browser binaries in the agent environment. The endpoint follows the format https://<region>.mcp.playwright.microsoft.com/playwrightworkspaces/<workspace-id>/mcp. Microsoft Entra ID is the recommended authentication method. A workspace access token sent in the x-api-key header also works. Note that the remote MCP server is in preview, with no service-level agreement. Do not use it for production workloads yet.

Microsoft Foundry browser automation, managed. The Foundry browser automation tool is generally available. It lets Foundry agents navigate websites, read information, and interact with web applications through a managed remote browser, powered by Azure Playwright Workspaces. You need no local browser or Playwright runtime. The tool exposes an MCP tool set for navigation, reading, form filling, dialogs, and tabs. It is the right choice when the agent runs inside a Foundry application and you want managed sessions, approvals, and supervision built in.

Hand-written Playwright scripts. For fixed, repeatable tasks, plain Playwright code beats an agent. A script is deterministic, fast, and cheap. It cannot adapt to a changed page layout, but it never improvises either. Use scripts for known flows. Use agents for open-ended tasks where the next step depends on what the page shows.

Vision screenshots vs accessibility snapshots

FactorAccessibility snapshotVision screenshot
What the model seesStructured tree of elements, roles, and labelsPixels, layout, and rendered text
PrecisionExact selectors and element referencesApproximate; needs coordinate mapping
Cost and speedCheap text, fast to processImage tokens cost more and process slower
Best forForms, navigation, standard web appsCanvas apps, visual checks, custom widgets
WeaknessThin or missing tree on custom-rendered pagesSmall text and dense layouts are hard to read

Playwright MCP uses snapshots by default. That is the right default. Add vision only where the snapshot fails. A common pattern is snapshot-first, then a screenshot to confirm a visual result such as a chart or a rendered PDF.

Building a safe browser agent

Browser agents take real actions. A wrong click can submit a form, buy a ticket, or delete data. Safety is part of the design, not an afterthought.

Require human approval for consequential actions. Microsoft’s guidance is explicit: require approval before the agent submits anything that matters. The agent can prepare a form, show a summary, and wait. The human taps approve. The agent submits once, verifies the confirmation number and success message, captures a screenshot, and closes the session.

Limit where the agent can go. Give it an allowlist of domains. Block login pages and payment flows unless the task truly needs them. Run each task in a fresh, isolated browser session. Close the session when the task ends so cookies and state do not leak into the next run.

Capture evidence. Screenshots and page snapshots at each step make failures debuggable. If a submission times out, inspect the page before deciding whether a retry is safe. A blind retry can double-submit an order or a form.

A minimal starter workflow

  1. Install Playwright MCP. Run npm install -g @playwright/mcp and npx playwright install chromium.
  2. Connect your assistant. Add the MCP server in VS Code, Claude Code, Cursor, or your editor of choice.
  3. Pick a read-only task first. Open a page, inspect its snapshot, and report the main heading. No clicks that change state.
  4. Add one safe action. A search query or a navigation step. Verify the result before going further.
  5. Add an approval gate. Any submit, purchase, or delete step waits for a human.
  6. Scale to managed browsers. Move to Playwright Workspaces or Foundry when you need concurrent sessions or team-wide use.

Bottom line

Playwright MCP is the best starting point for developers building browser agents locally. It is free, precise, and close to the DOM. Managed options from Microsoft Foundry and Playwright Workspaces fit teams that need scale, isolation, and supervision. Vision screenshots help where the accessibility tree runs thin, but snapshots should stay the default. Whatever you build, put a human approval gate in front of every consequential action. The agent does the clicking. You stay responsible for the outcome.