Agent-operable web UI
Modern web applications now serve three runtime audiences from one UI codebase:
-
Humans via the visual DOM and CSS
-
Assistive technology via ARIA attributes and the accessibility tree
-
AI agents and deterministic automation via a semantic state and action surface (a flat, typed index of active controls, their current state, and their legal actions)
This page defines that third abstraction layer, explains why raw DOM or accessibility-tree traversal is not enough for interactive apps, and compares WebMCP (document.modelContext) and Vercel UI SDK (vercel-labs/ui / ui-sdk.dev, co-developed with shadcn) as concrete implementations.
Why DOM and accessibility-tree traversal fall short
Agents can read the DOM or the accessibility tree, and for simple static pages that is enough. For stateful web applications, relying on DOM traversal or screenshot clicking fails in five structural ways:
| Failure mode | What happens with DOM / A11y traversal | What a semantic UI index changes |
|---|---|---|
Whole-tree reading & token bloat |
Real apps contain thousands of layout wrappers, portals, and chrome nodes; reading or diffing the whole tree every turn wastes context and latency. |
|
Invisible closed or virtualized state |
Closed dropdowns, unmounted popovers, and virtualized lists do not exist in the DOM until clicked and scrolled — forcing multi-turn open → re-read → scroll recursion. |
|
Imperative gesture fragility |
Synthesizing mouse coordinates, hover states, focus moves, and keystrokes breaks on CSS animations, z-index overlays, and refactors. |
|
Missing action contract |
The DOM shows what nodes exist now, not what legal transitions or argument schemas a widget accepts. |
Controls advertise explicit callable actions and typed schemas (or WebMCP |
No safety or provenance boundary |
A synthetic click looks identical to a human click; the app cannot gate destructive agent mutations or audit them separately. |
An |
Position in the essential web stack
Treat the agent-operable UI surface as a complementary layer, not a replacement for crawlability or accessibility:
| Layer | Audience & job | Dev-Centr baseline |
|---|---|---|
Public web crawlability |
Search crawlers and non-JS fetchers reading content routes (SSG/SSR HTML, |
Required for public content sites — see |
Accessibility baseline |
Keyboard users and screen readers operating UI controls (focus order, ARIA roles/states, contrast). |
Band B in Web delivery class. |
Agent-operable UI surface |
Runtime AI agents, browser assistants, and semantic E2E tests inspecting state and invoking typed UI actions safely. |
Band B for interactive web apps in Web delivery class (mark N/A with reason on static/brochure sites). |
|
Adopt the abstraction layer, not a single beta dependency.
Both the W3C WebMCP API and Vercel UI SDK are evolving (experimental/beta as of late 2026). Feature-detect |
Concrete implementations
WebMCP (document.modelContext)
WebMCP (Web Model Context Protocol) is an experimental browser API incubated in the W3C Web Machine Learning Community Group (with Chromium Origin Trials and experimental flags). It provides two registration paths directly in the browser:
-
Imperative API:
document.modelContext.registerTool({ name, description, inputSchema, execute })for stateful SPA logic and custom workflows. -
Declarative API: Standard HTML
<form>elements annotated withtoolnameandtooldescriptionattributes so simple form actions surface automatically as agent-callable tools.- Namespace note
-
Early 2026 Chromium previews exposed
navigator.modelContext. Mid-2026 W3C drafts moved the registry todocument.modelContextbecause tools are scoped to a document rather than the whole browser. Always targetdocument.modelContextbehind feature detection.
Vercel UI SDK (vercel-labs/ui)
UI SDKunchecked (vercel-labs/uiunchecked, Apache-2.0, public beta 0.1.0-beta.x, co-developed by Vercel Labs and shadcn) couples two layers that are usually maintained separately:
-
Authoring / behavior layer (agents as builders):
@ui-sdk/coreprovides 50+ atomic, framework-agnostic interaction behaviors (createPopup,createRovingFocus,createTypeahead,createSelection,createReorder, and more). A singledefinePrimitivedeclaration combines reactive state, public action methods, and structural slots, and thin framework adapters (@ui-sdk/react, Vue, Svelte, Solid, Web Components) render them viacreateParts. Because accessibility, focus recovery, and keyboard navigation live inside tested behaviors—and ship with an agent skill pack (npx skills@latest add vercel-labs/ui --skill ui-sdk)—coding agents compose custom controls without reinventing ARIA wiring. -
Runtime agent bridge (agents as operators):
Framework agent adapters (such as
@ui-sdk/react/agent) exposecreateAgent()with three structured primitives:-
snapshot()— returns mounted components, theirref/label, typed state, and exposed actions. -
query()— searches components or lazy/closed child options (such as items inside aSelectorCombobox) by text or label. -
act()— runs structured action steps directly against component APIs, guarded by anallowinterception hook anddetails.source === "agent"provenance. -
registerTools(agent, …)— bridges the same registry onto WebMCP (document.modelContext) automatically when the browser supports it.
-
Comparison with headless UI libraries
| Dimension | shadcn/ui |
Radix UI / Base UI / Zag.js | Vercel UI SDK (vercel-labs/ui) |
|---|---|---|---|
Layer |
Styled copy-in component kit and registry |
Complete headless components (Radix/Base UI) or per-widget state machines (Zag.js) |
Atomic interaction behaviors ( |
Framework scope |
Primarily React (community ports for others) |
React-first (Radix/Base UI); framework-agnostic core (Zag.js) |
React, Vue, Svelte, Solid, and Web Components from one primitive definition |
Runtime agent surface |
Standard DOM / ARIA only |
Standard DOM / ARIA only |
Built-in agent bridge ( |
Maturity (late 2026) |
Mature, widely deployed |
Mature |
Public beta ( |
Security and safety boundaries
An agent-operable UI surface makes legitimate automation cleaner, but it does not weaken the browser security model:
-
Never rely on client-side agent gates for authorization. Server endpoints must enforce authentication, RBAC, and tenant boundaries identically whether a request originates from a human click or an agent call.
-
Gate destructive and external-effect actions. Require explicit confirmation (via
allowhooks or UI confirmation flows) before delete, billing, permission-change, or external-send actions execute. -
Record provenance. Distinguish agent-initiated state transitions (
details.source === "agent"or equivalent audit tags) in client telemetry and diagnostics dumps. -
Beware indirect prompt injection. Tool outputs and component labels returned through
snapshot()/query()can contain untrusted user-generated text; keep sensitive secrets out of rendered labels and tool payloads.
Related
-
Add an agent-operable UI layer to a web app — step-by-step adoption paths (plain WebMCP and UI SDK)
-
Web delivery class — Band A/B/C matrix for browser-delivered apps
-
Auxiliary features checklist — printable checklist including the Web Band B item
-
Recommended tools — watch/reference status for UI SDK
-
UI-heavy web applications — dense SPA architecture and DOM-vs-canvas boundaries