Product Launch · XiaoHu Explains

Alibaba Open-Sources Page Agent: An Agent That Lives Inside the Webpage, Reading Text Instead of Screenshots to Operate the UI

MIT-licensed, model-agnostic — plug in any OpenAI-compatible text model and go. For now it only operates a single page view.

60-Second Rundown
  • An Alibaba team has open-sourced Page Agent, an agent library that runs as plain JavaScript inside the webpage itself, reading the page's textual structure (the DOM) directly to understand and operate the UI — no screenshots involved
  • The core technique is DOM dehydration: it compresses a page's thousands of nodes into a lean text map called FlatDomTree that keeps only the interactive elements, so an ordinary text model can pinpoint exactly which element to act on
  • It's MIT-licensed and model-agnostic, connecting through any OpenAI-compatible endpoint — it only needs text, not a multimodal model. The code inherits its DOM handling and prompt logic from browser-use
  • Because it runs inside the webpage, it automatically inherits the user's current login state, cookies, and permissions — no separate backend and no headless browser required
  • The limits are just as clear: safety rules live in the prompt rather than as hard constraints, the core library can only operate a single page, and cross-tab work needs an extra Chrome extension
1Who, and what they did

Alibaba open-sourced a browser agent that breaks the usual mold

An Alibaba team recently open-sourced Page Agent, an agent library that runs as plain JavaScript inside the webpage, understanding and operating the UI by reading the text-based DOM.

It lives inside the page like a real user, reading the page's text structure to click buttons and fill in forms — no headless browser, no screenshots, and no need for a model that can even see images.

Today's mainstream browser automation tools — Playwright, Selenium, Puppeteer, browser-use — all run as a separate process outside the browser, remotely puppeteering the page via screenshots or a debug protocol. Page Agent takes the opposite route: the agent logic itself is a piece of JavaScript embedded in the webpage, so it naturally inherits the user's current login state, cookies, and permissions. Integration is just one script tag or one npm install.
Submit ▍Click submit… Internal: a script clicks page elements directly External: a separate process controls remotely via screenshots/protocol
Same webpage, two paths: the agent living inside it, versus a robot arm reaching in from outside
2Setting up the comparison

Where the old approach's cost goes

To see what Page Agent actually saves, first look at how much baggage external tools carry just to operate one webpage. They never enter the page — they can only stand outside and direct it through a pane of glass.

01
A separate process
Playwright, Selenium, and the like all need to run a separate runtime or service outside the browser — a different program from your own application
02
A driver or debug protocol layer
They read and control the page remotely via WebDriver or CDP (Chrome DevTools Protocol, the browser's own remote debugging protocol) rather than entering the webpage itself
03
Often a multimodal model too
Many approaches feed the model a screenshot of the page and have a vision-capable model guess where the elements are, which pushes up inference cost

This externally-driven approach still works well for cross-site scraping and end-to-end testing. What Page Agent is trying to fix is a different kind of hassle: when the webpage is your own product and you can edit its code, why go through all that trouble at all.

3The key technique

Compressing an entire webpage into a text list

A modern webpage can have thousands of nodes, and handing the raw HTML straight to a model is slow and expensive. Page Agent's approach is to "dehydrate" the page first, keeping only the handful of things that can actually be operated on.

DOM dehydration

Upon receiving an instruction, the agent scans the entire DOM (Document Object Model — the element tree the browser parses a webpage into), finds every interactive element — buttons, links, input fields — and tags each with a sequential index plus a role and a text label. All the redundant decorative markup gets stripped away, and the whole page is compressed into a lean text map called FlatDomTree. What the model reads is this list, not pixels.

An analogy

It's like stripping all the body text out of a thick book and keeping only the chapter titles and page numbers from the table of contents. The model doesn't need to chew through the whole book — one glance at this table of contents tells it which page to flip to and which button to press.

How different what the model sees is, before and after dehydration

Before dehydration · Raw DOM
<div class="hdr"> <nav><ul><li><a href…> <span><svg>…</svg></span> <div class="wrap"><div>… <button class="btn primary"…> <input type="text" name…> …thousands of messy nodes
After dehydration · FlatDomTree
[0] link   "Home" [1] input  Email [2] input  Password [3] button "Log in" [4] button "Submit expense"

The original demo page lays this loop out directly: a "Dehydrated DOM" panel shows the list the model is reading, while an "Action trace" panel next to it updates step by step as the instruction executes — you can watch it click through the sequence.

Dehydrated DOM
[0] link "Home"
[1] input Email
[2] input Password
[3] button "Log in"
[4] button "Submit expense"
Action trace
updateTree · generate the list
inputText [1] · fill in email
inputText [2] · fill in password
clickElement [3] · click log in
4Under the hood

What happens once the instruction comes in

From a single sentence of natural language to an actual click on the page, there's a fixed closed loop in between. The dirty work is handled by a component called PageController.

Natural-language instructionexecute()
Scan the DOMupdateTree
Generate FlatDomTreethe text list
Model decideswhich index to pick
Execute the actionclick / input / scroll

PageController exposes exactly these actions, operating on elements by index:

PageController · core action calls
await this.pageController.updateTree()
await this.pageController.clickElement(index)
await this.pageController.inputText(index, text)
await this.pageController.scroll({ down: true, numPages: 1 })

The whole monorepo splits responsibilities across three small packages:

@page-agent/coreheadless agent core logic
page-agentthe full entry-point class with a UI panel
@page-agent/page-controllerhandles DOM extraction and element indexing, with an optional SimulatorMask for visual feedback

Three guardrails in the developer's hands

Action allowlist
restrict the agent to only the actions you specify — nothing else is allowed
Data masking
hide sensitive fields like passwords so they're never sent to the model
Custom knowledge
inject your own business rules so it follows your domain's conventions
5Head-to-head comparison

Against other tools, who should use it

This comparison table is about scenario, not speed. The four approaches run in different places and read the page in different ways — each has its own turf.

ApproachRuns whereHow it reads the pageIntegration costBest for
Page AgentInside the webpage (client-side JS)Dehydrated text DOMOne script tag or npmAn operational copilot inside your own product
Selenium / Playwright / PuppeteerExternal processReads the DOM via a driver (WebDriver/CDP)Driver plus a runtime or serviceScripted end-to-end testing
browser-useExternal processDOM plus optional visionPython plus a browserAn autonomous, multi-site agent
WebMCPServer-side toolStructured function callsRequires the standard to see wide adoptionAgent-native tool calling
What WebMCP is

It takes a different route: the webpage wraps its own functionality into structured "tool" functions and exposes them directly for an agent to call, relying on a standardized interface. Page Agent reads DOM text, WebMCP relies on a standard protocol — one works without touching the webpage's code, the other has to wait for its interface standard to gain broad acceptance.

The conclusion comes down to scope of use: Page Agent fits inside a product you control and can edit; if you need to scrape someone else's site, or work against a locked-down environment, external driving still wins.

6Where it lands

What you can actually do with it

Because it lives right inside your application, it can actually finish an operation for the user, not just tell them beside it how to click. The original piece gives four concrete examples.

🤖
An operational copilot built into the product
Give a SaaS product an assistant that can operate on the user's behalf. A support bot that actually finishes the steps for the user, instead of just describing them.
📝
One sentence fills a multi-step form
Compress a long, multi-step form in an ERP or CRM into a single sentence. The user types submit a $50 lunch expense from yesterday, and it handles the page-flipping and data entry itself.
🎙️
Voice and accessibility
Pair it with the Web Speech API for voice control — any webpage becomes reachable via natural language, and it can also read friendly prompts aloud for screen readers.
🧰
Adding a natural-language entry point to a legacy system
Wrap it around an old internal tool with no API and add a command bar, without touching the original code.
7How to get started

The lowest-cost path is a single script tag

If you just want to get a feel for it, one script tag loads Page Agent bundled with a free test model, ready to try right on the page.

For evaluation · one-line integration (includes free test AI)
<script src="https://cdn.jsdelivr.net/npm/page-agent@1.10.0/dist/iife/page-agent.demo.js" crossorigin="true"></script>
MIT
Open-source license, codebase is TypeScript-first
1.10.0
The demo version number you can try directly on jsDelivr's CDN

For production use, install the package and swap in your own endpoint:

For production · npm install and configure your own endpoint
import { PageAgent } from 'page-agent'

const agent = new PageAgent({
  model: 'qwen3.5-plus',
  baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
  apiKey: 'YOUR_API_KEY',
  language: 'en-US',
})

await agent.execute('Click the login button')

The model and baseURL accept any OpenAI-compatible provider — switching models is basically just swapping the base URL and key.

⚠️
That demo endpoint is for technical evaluation only. And an apiKey written directly into new PageAgent gets bundled straight into your front-end code — in production, requests need to go through your own backend as a proxy; never expose the key on the client. The agent also supports popping up a confirmation before executing each critical action.
8The real boundaries

What it can't do

This "live inside the webpage" approach comes with its own inherent trade-offs, and the official docs are upfront about the limits. These points need to be on the table before you use it.

Safety rules written into the prompt are only a suggestion

Rules like "never auto-submit a payment form" are placed in the system prompt. They're persuasive guidance, not a hard guarantee. For sensitive or destructive operations, server-side validation still has to stay in place — instructions in the prompt can't be your only line of defense.

The core library only handles a single page

The core library targets interaction within a single view; on its own it can't move between tabs or windows. For cross-page automation, you need the optional Chrome extension, which requires its own installation and authorization. There's also a Beta-stage MCP server that lets external agents like Claude Desktop or Copilot drive it in reverse.

Expand: what each of the three runtime locations solves

The core library runs inside the page and handles single-page operation; the Chrome extension adds cross-tab capability, at the cost of an install and permissions; the Beta MCP server turns Page Agent into a tool that external agents can call, connecting it back to external agents like Claude Desktop and Copilot. Each of the three layers covers a different scope, and the further out you go, the higher the cost of setup and authorization.

Back to the opening line: Page Agent and mainstream tools take two different roads — one embeds itself inside the webpage to read text, the other stands outside and remotely operates via screenshots and protocols. It extends where browser automation can actually land, from "an external script controlling someone else's webpage" to "a natural-language operating layer built right into the product."

The agent lives inside the webpage as plain JavaScript. It reads the live DOM as text and acts as the real user. No headless browser, no screenshots, no multi-modal model. , MarkTechPost, 2026-07-02
This piece is based on MarkTechPost's reporting; the facts and code samples are from the original. Project open-source repo: github.com/alibaba/page-agent (MIT license, TypeScript). Compiled by XiaoHu · AI Explainer.