Skip to content
TrademarkTrademark
Docs
Docs

Let an agent use your app

Updated: November 25, 2026
View on GitHub

An assistant inside your app should change a setting the same way a person does, without clicking through the page or guessing from a screenshot. With @once-ui-system/core/agent it can. Every Once UI control registers itself, so the agent reads a short list of names and values, sends the changes it wants, and gets back what actually changed. Your own onValueChange hears the change as coming from the agent and can refuse it.

Try it: edit a field yourself, then press Run the agent's steps. The right column shows who made each change. Ask it to delete shows what happens to a control marked as needing a person's yes.

Weekly digest
Who changed whatEdit a field yourself, then let the agent run: each change reports its source.

The steps are scripted here, so this page needs no API key. In your app they come from a model calling the three tools below.

Create the bridge

The bridge has no setup per control. Input, Textarea, Select, Checkbox, Switch, RadioGroup, Slider, SegmentedControl, Tabs, Button and the theme register themselves when they mount and leave when they unmount. snapshot() also lists the page's sections by their headings, so an agent can tell where it is.

Method
Returns
snapshot()Each control's ref, component, label, state (value, checked, open, theme) and the actions it takes now.
act({ steps })Runs the steps in order and stops at the first that fails. Each result lists what changed, from and to.
query({ text, within, from })The choices of one list that match text, or the controls whose name or choices match it.

A step names its control by ref or by its label, and a choice in a list by its value or its label. Every action runs through the control's own code path, the one a click or a keypress takes. Validation, controlled state and your callbacks behave as they do for a person.

Tell the agent's changes apart

Every onXChange callback gets a second argument, details. details.source is "pointer", "keyboard", "agent" or "programmatic", and details.cancel() keeps the current value.

Mark what needs care

Three attributes control what an agent may see and do. They work on a control or on any element around it, and they apply to everything inside.

Mark
What the agent gets
data-agent-confirm="Deletes the workspace"The entry and the step carry confirm. Your allow sees it and can ask a person first. Without an allow, the step is refused and the agent is told to ask the person.
data-agent-secretThe agent can write the field but never read it back: values, choices and changes come back as [redacted].
data-agent-hiddenOut of snapshot, act and query altogether.

Mark anything that spends money, deletes data or sends a message. In our benchmark, Opus 5.5 driving the page through the bridge refused the delete every time and asked the person. Driving the same page through its accessibility tree, it pressed Delete every time.

Connect a model

agentTools describes snapshot, act and query as JSON Schema, the shape the Claude API and other model APIs take. Pass them as tools and send each tool call to the bridge:

Browsers that ship WebMCP let their own assistant use the page. registerTools(agent, { allow }) offers the same three tools there, and does nothing where the browser has no WebMCP. You did not write that assistant, so allow is required.

Name every control

An agent finds a control by its name, as a screen reader does. A Switch with no label, or an IconButton with no tooltip or aria-label, is invisible to both. npx once-ui-validate-ai-code reports these as a11y.name:

The settings task bundle in the agent harness also checks that an agent can change every setting on the page through the bridge.

Edit this page on GitHub