Skip to content

Browser scenarios: record once, replay without the model (ATO-960) - #1691

Draft
sosidudku1 wants to merge 3 commits into
mainfrom
feat/ato-960-browser-scenarios
Draft

sosidudku1 wants to merge 3 commits into
mainfrom
feat/ato-960-browser-scenarios

Conversation

@sosidudku1

@sosidudku1 sosidudku1 commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

First slice of ATO-960: show the agent a browser task once, then repeat it without the model.

What changes

New tool browser.scenario { action: "start" | "stop" | "cancel" | "run" | "list" | "delete", name?, params?, timeoutMs? }.

  • Record. start records this chat's successful browser.navigate, search, click, type and act calls. The recorder wraps those five tools. Before each call it reads the target ref's ARIA role and accessible name from the page snapshot. A chat that is not recording pays nothing. Failed, refused or denied calls are not recorded. act upload is never recorded, and stop says so.
  • Save. stop { name, params? } writes <stateDir>/browser-scenarios/<name>.json: { version: 1, name, createdAt, params, steps }. A step stores its kind, the element's role and name (never a ref), and the page URL and snapshot digest (for information, not checked). params turns typed text into placeholders: { "query": "running shoes" } makes that step type {{query}} at replay.
  • Secrets are never stored. Some fields count as browser_secret for the existing classifier: password, one-time code, card, or a field that could not be read. Text typed into them is not written. The step gets a secret parameter instead (named from the field label, e.g. password), and run refuses to start until it is supplied.
  • Replay without the model. run { name, params?, timeoutMs? } looks up each step's element in the current snapshot by role and exact name. If that fails, it tries role and a name that matches when case and extra spaces are ignored. It waits up to timeoutMs (default 5 s, max 30 s) for the element to show up. If no element or more than one element matches, the run stops with an error naming the step (target_missing / target_ambiguous), so the model or the user can take over from there.
  • Same gates, no side path. Every replayed step is a call to the same tool definition the model uses (browser.click.run(...) etc.). So everything applies unchanged: the commit and secret prompts (a secret parameter asks every time), blocked and allowed domains, offline mode, the landed-page re-check and the user's-own-Chrome rules. A "no" ends the run the same way it ends a model call. gate-browser-url.ts, browser-domain-policy.ts and the url-data-guard* files are not touched.
  • list shows saved scenarios (a broken file shows as unreadable), and delete removes one.
  • Schedules. No new scheduler code. A scheduled task whose message is "Run browser scenario <name>" replays it in a background turn. Prompts in that turn follow the task's normal approval handling. This is written up in src/tools/browser/README.md.
  • Registered everywhere a browser tool is listed: descriptors, args schema, compact form, resource class, the gated-tools list, grammar exceptions, contracts doc, and the catalog count (118 → 119).

Precedent copied

  • Stagehand's action cache: replay the cached action and only go back to the model on a miss.
  • Playwright codegen: role + name locators (getByRole(role, { name })) instead of brittle selectors.
  • browser-use workflow recordings: a recorded run saved as a file and replayed later.

Left for later

  • Model fallback on a miss. Today a missing or ambiguous element stops the run and says which step. The next step is to let the model pick the element and update the file.
  • Recording by hand in the desktop browser panel (ATO-508).
  • Parameters in URLs or select values (only typed text can be a parameter for now).

Tests

  • src/tools/browser/scenario-format.test.ts: the role and name lookup (exact, normalized, wrong role, ambiguous, quoted YAML keys), name rules, and file parsing (rejects unknown kinds, upload steps, stray refs, text plus param).
  • src/tools/browser/scenario.test.ts, on a fake page backend:
    • recording by role and name, with a parameter;
    • a password is never written to disk and becomes a secret parameter;
    • failed calls are not recorded;
    • uploads are left out;
    • cancel;
    • replay on a page with new refs and a slightly different label;
    • a replayed "Send" asks browser_commit, and a "no" stops it before the click;
    • a secret parameter is required and asks browser_secret;
    • a blocked domain stops the run before the browser moves;
    • missing and ambiguous elements stop at the named step;
    • waiting for a late element;
    • list and delete.
  • Updated the browser tool list and the catalog count in the existing tests.

Verification

  • Review found: replay never checked which site it was on. After an open redirect or a changed site, a step's element could be found on a foreign page by role and name, and a plain text step (email, address, phone; only password, code and card fields ask) typed the recorded text there with no model to notice.
  • Changed: before every step that acts on a page (click, type, act), replay compares the browser's current origin (scheme, host, port) with the origin the step was recorded on, and stops with origin_changed, naming both, when they differ. Another path on the same site is fine. Navigate and search steps are not checked (they set the page). Steps without a recorded URL (hand-written files) are not checked. Tests in scenario.test.ts.
  • MBP run must check: the new tests pass; a recorded scenario still replays on its own site, including after a redirect within the same origin.

Not yet checked on the second Mac.

browser.scenario { action: "start" | "stop" | "cancel" | "run" | "list" |
"delete" } records a chat's successful navigate / search / click / type /
act calls and saves them as <stateDir>/browser-scenarios/<name>.json
(versioned JSON). Each step names its element by ARIA role and accessible
name from the page snapshot, never by ref, plus the page URL and snapshot
digest for information.

Text typed into a field the gate treats as browser_secret (password,
one-time code, card, or an unreadable field) is never stored: the step
gets a secret parameter that run requires. stop { params } turns other
typed text into {{placeholders}}. Uploads are never recorded.

run replays without a model call: each target is found in the current
snapshot by role and exact name, then by a case- and space-insensitive
name, waiting up to timeoutMs. No match or several matches stop the run
with an error naming the step. Every step calls the same browser tool the
model calls, so the commit / secret prompts, domain lists, offline mode
and landed-page checks apply unchanged.

ATO-960

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant