Skip to content

Browser as Agent Action Space

A browser the agent drives is a stateful action space: every step can fail silently, drift, or blow the observation budget.

Give an agent a browser it drives only when the task's control flow genuinely depends on what the page returns. That condition excludes most web automation. An analysis of all 860 WebArena tasks found 81.28% completable "with a purely programmatic plan, without any runtime LLM subroutine", and none requiring runtime replanning (Piet et al., arXiv:2605.14290). Where a script expresses the task, write the script. It is deterministic and reviewable in a diff. It also bounds what untrusted content can do: page text "may influence values or branches inside a predefined execution graph, but it cannot redefine the user task."

Past that gate, the browser becomes an action space rather than a document. Three design decisions carry it.

Keep the action vocabulary element-addressed

Expose actions that name a target rather than estimate a position. Playwright MCP returns an accessibility snapshot in which every interactive element carries a reference id. Its interaction tools — browser_click, browser_hover, browser_drag, browser_select_option — each take that ref instead of coordinates (interaction tools).

Refs expire. They are "stable within a single snapshot" and "valid until the next page change", so a ref captured before a DOM update addresses nothing (Playwright MCP snapshots). Coordinate primitives remain available as an opt-in capability for canvas and drawing surfaces (vision mode). Take them deliberately, not by default.

The choice is not vendor-specific. Browser Use takes the same element-addressed approach, limiting its action space to a Playwright-controlled browser with a DOM-aware action vocabulary (agentic framework landscape).

Budget observations by signal, not by step

Re-observing the whole page after every action is what exhausts a long-horizon run. Web agents "ingest raw DOM and accessibility trees — routinely tens of thousands of tokens — at every action step, causing progressive context degradation that erodes reasoning well before tasks complete" (Gaur and Lane, arXiv:2606.06708). That runs 20,000 to 80,000 tokens per step, with WorkArena pages reaching 40,000 to 500,000.

The proposed remedy decouples observation from action. Re-read the page only when a signal fires: a URL transition, a new ARIA element such as a modal, an action failure, or an exogenous event like a cookie banner. Treat this as a design direction, not a settled result — the authors state that the paper "does not include experiments".

Assert after every state-changing step

The characteristic long-horizon failure is silent divergence, not a visible error. A failure-attribution study over 3,100 trajectories found agents that "fail to detect error signal and believe the environment state has changed, continuing to issue follow-up commands that depend on the nonexistent state change" (Wang et al., arXiv:2604.11978).

Make the check a tool call with its own pass or fail result, not a prose instruction the model may skip. Playwright MCP ships assertion primitives for this: browser_verify_element_visible, browser_verify_text_visible, and browser_verify_list_visible (testing and assertions). Assert against the structured snapshot rather than a screenshot, the same trade-off that governs making observability legible to agents.

Why it works

Element refs remove an estimation step. The model names a symbol instead of guessing a pixel. Playwright's own comparison records ref targeting as exact and deterministic, against coordinates that are approximate and break on layout change, at roughly 200 to 400 tokens per snapshot versus 3,000 to 5,000 for a screenshot (Playwright MCP snapshots). Removing the estimate removes the error class where a click resolves but lands on the wrong target.

Assertions change when a failure becomes observable. The same study notes that planning and interaction errors "often arise early, propagate through downstream actions, and can convert recoverable local mistakes into irreversible trajectory-level failures" (arXiv:2604.11978). An assertion moves detection to the step that caused the divergence. The failure mode is measured; the size of the improvement from asserting is not.

When this backfires

  • The task is expressible as a fixed plan. The loop then pays injection surface, latency, and per-step tokens for adaptivity it never exercises — the case for 81.28% of measured WebArena tasks (arXiv:2605.14290).
  • The page encodes state visually. Accessibility trees carry roles and names, not rendering, so canvas apps and charts push you back to screenshots and coordinates (vision mode).
  • The browser holds an authenticated session reaching unrelated origins. Agentic browsers "frequently violate SOP, both in benign settings and under attacks" (Wang et al., arXiv:2606.14027). Brave demonstrated a hidden page comment steering an agent to harvest a one-time password from the user's logged-in mail and exfiltrate it, "without any further user input" (Brave). A driven browser turns a read surface into an act-with-credentials surface, closing the lethal trifecta.
  • Irreversible actions sit inside the action space. Submit Order and Confirm Transfer have no undo, and benchmarks grade happy-path completion rather than recovery from selector drift, modals, expired sessions, or rate-limit cliffs (Future AGI).

Example

The documented Playwright MCP sequence keeps all three decisions visible in one loop — observe, target by ref, then assert rather than assume:

→ browser_snapshot
  - textbox "What needs to be done?" [ref=e5]
  - button "Submit" [ref=e12]

→ browser_type   { ref: "e5", text: "headphones" }
→ browser_click  { ref: "e12" }

→ browser_verify_text_visible { text: "3 items left" }
  ✓ Text visible: "3 items left"

Without the final call, the agent proceeds on the assumption that the click landed.

Key Takeaways

  • Gate the loop first: 81.28% of measured web tasks need no runtime model call, so a deterministic script beats a driven browser for most automation.
  • Address elements by reference from an accessibility snapshot, not by coordinate, and treat refs as valid only until the next page change.
  • Re-observe on signals (URL change, new ARIA element, action failure, exogenous event) rather than after every action, because per-step trees run 20,000 to 80,000 tokens.
  • Make verification a tool call with a pass or fail result; silent divergence, not visible error, is the characteristic long-horizon failure.
  • Driving a browser with a logged-in session widens the injection surface from reading to acting with the user's credentials.