Repository navigation
Studio: let models use the browser panel - #13372
Conversation
Browser tools (navigate, snapshot, find, click, type, select, scroll, press key, screenshot) that any tool loop can call: GGUF, safetensors/MLX and external API providers. The chat tab runs each action in the agent's tab of the browser panel and posts the result back; the panel asks the user before sign-ins, POST forms, purchases and new sites, and never types into password or payment fields.
Settings > Browser gains a Browser use section: turn browser use on or off, choose whether models may read the browsing history (always ask, always allow, never; a new browser_history tool), and Agent permissions with a default and per-site rules for browsing, actions (sign-ins, form posts, purchases) and downloads. Password and payment fields stay off-limits whatever the rules say.
|
@codex review |
|
@codex security review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (3)
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2acd463ff5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| url = _one_line(_clip(result.get("url"), _MAX_URL_CHARS)) | ||
| if url.lower().startswith(("http://", "https://")) and website_policy: | ||
| allowed, _reason, host = check_url_access(url, website_policy) | ||
| if not allowed: |
There was a problem hiding this comment.
Revalidate public resolution for browser results
On desktop native views, a hostname is resolved by the backend before the action but then resolved independently by the WebView; a DNS-rebinding host can therefore pass the initial public-address check and subsequently resolve to a private service. This result-side check runs only for a nonempty website policy and only calls the domain-policy validator, which does not reject private DNS results, so the local page contents are returned to the model. Reapply the public-host resolver check to every final HTTP(S) result before formatting its content.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not reachable: native requests go through browser_proxy.rs, which resolves the host itself and refuses private answers, and the proxied path pins the resolved IP, so a rebinding answer after the check never connects.
Gate Enter/Space on buttons and cross-site form actions, re-check the landing site after redirects, honour submitter formaction/formmethod, redact card and secret field values, skip hidden elements in find, keep refs unique across pages, fence the page title, stop the running action on Stop, size the tab's deadline from the backend wait and retry result posts.
Recheck the page's site before every read or action, gate checkbox selects and Enter/Space on submit buttons, submit on Enter only from text fields, find password fields joined with form=, build control names from visible text, keep page words out of errors, mask secret fields in screenshots, expire queued actions from receipt, give each page a non-overlapping ref range, and apply the initiating site's download rule.
|
@codex security review |
Ask before following a link whose href is read at click time, submit Enter through the button the gate described, read headings from visible text, keep site-name approval off shared hosts and partial host matches, hold Backspace/Delete to the typing rules, and recognise consequential labels in Studio's UI languages.
… site matching
- A page script's error text reached the model outside the untrusted fence. The panel now
sends it as pageError and the server fences it.
- WebKit acts on a synthetic Enter keypress (implicit submit, button click), so Enter in a
field or on a button ran twice there. press() now skips its own action when the key
already submitted or clicked.
- A trailing dot (evil.com.) slipped past blocked site rules and the website policy on
link, redirect and form paths.
- Naming a site ("search wikipedia") no longer approves a lookalike on another TLD
(wikipedia.xyz) without asking.
- example.com vs *.example.com on a subdomain no longer depends on save order.
Pass only the page agent's own fixed error messages to the model, judge a dropdown change by the option chosen, and ask before Backspace or Delete outside a text field.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0042bf9a04
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const shown = wholePage || onScreen(rect); | ||
| const role = roleOf(el); | ||
| if (role) { | ||
| if (sized(rect) || role === "checkbox" || role === "radio") { |
There was a problem hiding this comment.
Exclude hidden controls from full-page snapshots
When full_page is true, shown is unconditionally true, and this size exception assigns refs to zero-sized checkboxes and radio buttons whose ancestor has display: none (the descendant's own computed display is not necessarily none). The model can then call browser_select on that ref, and choose() ultimately invokes click() programmatically despite the control being invisible, potentially changing conditional or internal form state the user cannot see. Check ancestor visibility or otherwise exclude zero-sized controls before emitting these refs.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not reproducible: walk() returns at hidden(el, style) before recursing, so nothing under a display:none ancestor is visited or given a ref. Checked in Chromium with fullPage: a checkbox inside a display:none div gets no ref; the zero-size exception only applies to visible custom-styled checkboxes and radios, which is its purpose.
| } | ||
| // A native move starts when the view reports it; loading from now, so the wait below sees it. | ||
| if ((nativeMove || (native && action.op === "reload")) && hasNativeView(tab.id)) store.updateTab(tab.id, { loading: true }); | ||
| if (nativeMove) nativeAction(tab.id, action.op as "back" | "forward"); |
There was a problem hiding this comment.
Block native history moves with unknown destinations
In a desktop native view, Back or Forward can point to history created before the current agent trail, so destination is empty and this branch substitutes a generic user prompt before still calling nativeAction. The destination therefore loads without being checked against action.policy or a site rule; arrive() only withholds the result after the blocked host has already received the request. This is especially reachable when a first-turn chat is re-keyed and enterScope() clears trail, so unknown native-history moves should be refused unless their URL can be validated before navigation.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Below the bar: with no known destination the move already asks the user first (Open the previous page?), the entry is history the user made in that tab, and arrive() still withholds a blocked page from the model. Refusing outright would only remove the user's choice.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2517b1118
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| elif ( | ||
| self._deduplicate_tool_calls | ||
| and key in self._successful_keys | ||
| and tool_name not in BROWSER_TOOL_NAMES | ||
| ): |
There was a problem hiding this comment.
Deduplicate mutating browser calls within one tool batch
When deduplicate_tool_calls is enabled, this exempts every browser tool, including browser_click, browser_select, and browser_type with submit, rather than only state-dependent reads and scrolling. If a model emits the same mutating call twice in one assistant turn, the second call is prepared after the first succeeds and the frontend queue executes it again, even though the model has not observed any intervening page state; this can toggle a setting twice or submit/purchase twice. Preserve deduplication for mutating browser operations within a single batch while still allowing deliberate repeats after a later observation.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Intended: browser calls are exempt from identical-call collapsing because each acts on the page as it is then (two scrolls are two scrolls), and the textual-fallback collapse now matches the structured path, which never collapsed. A repeated click is not a silent repeat of a consequential action: buy, send, delete, sign-in and POST submits each ask in the agent bar, every time.
| # A browser call acts on the page as it is then: two scrolls are two scrolls. | ||
| elif _key in seen_keys and _fn.get("name") not in BROWSER_TOOL_NAMES: |
There was a problem hiding this comment.
Continue browser nudges after safetensors tool turns
The safetensors/MLX loop special-cases browser calls only for deduplication, while its no-call nudge still requires that no tool has ever executed (safetensors_agentic.py:1293). After the first browser action, a model response such as “I’ll click the result” without an actual call is therefore accepted as the final answer and the browsing task stops, whereas the GGUF path added a per-browser-turn post-tool nudge reset specifically for this case. Apply the same bounded post-tool browser nudge behavior on this backend.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Below the bar for this PR: nothing runs wrongly; a model that announces a step without calling it ends its turn and the user can say continue. Matching the GGUF per-browser-turn nudge budget in the safetensors loop is a follow-up that needs a safetensors browser run to tune.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cbe1a864fe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if ((tag === "textarea" || tag === "input") && (field.disabled || field.readOnly)) { | ||
| return { ok: false, error: `${ref} is disabled or read-only.` }; | ||
| } | ||
| if (tag === "textarea" || (tag === "input" && TEXT_INPUTS.has(field.type.toLowerCase()))) { |
There was a problem hiding this comment.
Support date-like inputs in browser_type
For <input type="date"> and the related time, datetime-local, month, and week types, roleOf() exposes the control to the model as a textbox, but this condition rejects it because TEXT_INPUTS omits those types. On common booking and scheduling forms, the model therefore receives a valid ref yet browser_type always reports that it is not a text field; accept these native input types and set their correctly formatted values.
Useful? React with 👍 / 👎.
| const position = getComputedStyle(node).position; | ||
| if (position === "fixed" || position === "sticky") return node; |
There was a problem hiding this comment.
Reject clicks covered by absolute overlays
When an element is obscured by an absolutely positioned modal, popover, or other in-page overlay, elementFromPoint() returns the covering element but this loop only treats fixed or sticky ancestors as overlays. It consequently returns null and the subsequent programmatic el.click() activates a control that the user could not click at that location; reject unrelated hit-test results regardless of whether the covering layer uses absolute, while retaining explicit exceptions for labels or styled controls.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: treating any absolutely positioned layer over the target as a cover would refuse ordinary clicks, since styled checkboxes, labels and icon overlays commonly sit on top of their control as absolute siblings. Fixed and sticky layers are the modal case the hit test is for.
| el.value = option.value; | ||
| el.dispatchEvent(new Event("input", { bubbles: true })); | ||
| el.dispatchEvent(new Event("change", { bubbles: true })); |
There was a problem hiding this comment.
Refuse selections on disabled dropdowns
For a disabled native <select>, this branch writes its value and dispatches input and change events without checking el.disabled. Unlike a real user interaction, browser_select can therefore change a locked control and trigger application handlers even though the snapshot marks it disabled; return the existing disabled/read-only error before mutating the selection.
Useful? React with 👍 / 👎.
| const answer = await pageCall(tab, op); | ||
| if (!answer.ok) return { ok: false, error: answer.error ?? "the page could not be read." }; | ||
| if (op.op === "snapshot" || op.op === "find") pageLinks = new Set(answer.links ?? []); | ||
| const fresh = useBrowserStore.getState().tabs.find((candidate) => candidate.id === tab.id) ?? tab; |
There was a problem hiding this comment.
Recheck the page after awaiting an observation
If the tab starts an automatic or user-initiated navigation after stillAllowed() but while pageCall() is awaited, the call can install on and snapshot the newly loaded document; this function then returns that document's text and fresh URL without running arrive() or stillAllowed() for the new site. Consequently a browser_snapshot or browser_find can expose a site that the user's browsing rules require approving or block entirely, so compare the URL/document after the call and gate it before returning the answer.
Useful? React with 👍 / 👎.
What this does
Chat models can now drive the browser panel beside the chat. Turn on Browser use from the composer's + menu: a Browser pill appears, and the model gets browser tools. It opens pages in its own tab in the panel, reads them, clicks, types, picks options and scrolls while you watch. Local GGUF models, safetensors/MLX models and external API providers all use the same tools, because every tool loop already goes through
execute_tool.Tools (
core/inference/browser_agent.py):browser_navigate(also back, forward, reload),browser_snapshot,browser_find,browser_click,browser_type,browser_select,browser_scroll,browser_press_key. There is alsobrowser_screenshot, which is offered only to vision models in the desktop app, where the panel can be captured without a share prompt.Settings > Browser
A new Browser use section at the top of the Browser settings:
Let models use the browser. Turns browser use on or off. It is the same switch as the composer's Browser pill.
Browsing history. Choose whether models can read your history through a new
browser_historytool: Always ask (the default), Always allow, or Never. With Never, the tool isn't offered at all.Agent permissions. A default, plus exceptions for sites or patterns (
example.com,*.example.com), with three columns:Password, card and one-time-code fields are never filled, whatever these settings say. A site added here starts as Always allow for browsing, with the action and download prompts kept. Stored values are checked when loaded, so a bad value falls back to the default rather than to allow.
The existing link, download, history and annotation settings already cover the rest of the reference layout. Some items in the reference don't apply to Studio's browser:
How it works
The model reads the page as text, not screenshots. This is the approach browser-use, Playwright MCP, agent-browser and Chrome DevTools MCP all share. Each visible element is one line with a stable ref:
By default only the visible part of the page is read, capped at about 8k characters.
full_page,browser_findand scrolling reach the rest. Refs stay the same until the page navigates. A stale ref returns an error that tells the model to read the page again. Each action returns the updated page, so one step is one model turn. This works for small text-only models.The page script (
features/browser/agent/page-agent.ts) is the same on both surfaces:agentcommand in the frame'sboot();browser_view_agentTauri command. It uses the same template andeval_with_callbackpattern as annotate and is gated byrequire_main.The tool loop runs on the server, and the browser lives in the tab. A browser tool sends its request to the tab as a
tool_outputframe carryingbrowser_action;tool_stream_execnow passes dicts through. The chat tab runs the action and answers onPOST /api/inference/browser-action-result. The tool waits for that answer the way it waits on tool approvals (state/browser_actions.py):Turns with browser tools use the live-tab stream (
BROWSER_EXECUTED_TOOLS), which was reserved for this case.Off by default. The tools are never part of the default catalog: they are offered only when the chat names them in
enabled_tools, and only to requests that take Studio's UI frames (an API client could never answer them).Safety
The browser runs the model's actions; it does not trust the model. These rules are enforced in code, since prompt injection will sometimes work on small models:
Addresses are checked twice.
evil.com.isevil.com).The panel asks before consequential actions, in every permission mode:
The agent bar above the page says exactly what the action is and where the form goes, with Allow, Deny and Stop. If the user declines, the model is told and the action does not run.
Some fields are never filled:
Hidden text and labels don't reach the model.
display:none,aria-hidden, 1px screen-reader text and text under 2px (font-size:0) are left out of the snapshot.Page text is fenced as untrusted. It is wrapped in
<untrusted_web_content>, and the page cannot close the fence. The tool descriptions tell the model that page text is data, not instructions.The agent works only in its own tab. The model can't reach the user's other tabs. The proxied frame keeps no cookies, so on the web build the agent is always logged out.
Verified
Backend:
tests/test_browser_agent.py(30 tests) covers:.localhosts,file:/javascript:, credentials in URLs, website policy;Existing streaming, permission and approval tests pass.
Frontend: typecheck, the full
npm testsuite,npm run build,i18n:check:strictandbundle:check(within budget).tests/browser-agent-gate.test.tscovers the gates.Page script: run against a fixture page in Playwright Chromium and WebKit. Both pass the same checks:
Desktop:
cargo testfor the new command's script splicing.End to end on CPU in an isolated Studio, with
unsloth/gemma-4-E2B-it-GGUF(UD-Q4_K_XL):Screenshots (web UI, gemma-4-E2B-it-GGUF on CPU)
The model opened Hacker News in the panel and answered from the page:
The search form posts, so the agent bar asks before submitting it:
With Browsing history on Always ask,
browser_historywaits for the user:Not tested here
browser_screenshot, which needs the desktop app and a vision model.execute_tooland stream wrapper, but no GPU is available here.Known limits
isTrustedwon't react.Before / after (merge base 2640084 vs head aedb68c)
Composer + menu: the head build lists Browser use under Chat with files (MCP moved under More); the merge base has no such item.
Settings > Browser: the head build opens with the new Browser use section (the switch, Browsing history, Agent permissions with defaults Ask for new sites / Requires approval / Requires approval). The switch shows on only because the menu item was clicked first in the same run; it is the same setting.