Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

Merge origin/main into codex/monitoring-regression-audit and resolve PR #3199 conflicts

Codex release-state testc3b2aebdb10f
diff --cc CHANGELOG.md
index aa5caa464,e90a17a00..6a8f8a5b6
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -6,31 -6,17 +6,41 @@@ This changelog was generated from the r
## [Unreleased]
+ ## [40.8.0] - 2026-10-16
+
+ ### Added
+ - `browser_batch` runs predictable browser actions in order in one model round trip on Chrome and Firefox. Mid allows up to 6 actions and Full up to 10; Dev inherits its provider tier. Each action keeps its normal permission and verification checks, and failures or submits stop the remaining work for a fresh turn. A final page read can follow navigation. Ask and Compact keep their existing tool surface; an internal `browserBatchEnabled` switch disables batching.
+
### Fixed
+- X: typing a post into X's compose window no longer fails, and no longer ends with "Stopped because the page kept changing". Before typing into X's editor, WebBrain clicks it once with a real mouse click. X answers that click by drawing its bold/italic bubble right where the click landed, over the middle of the empty editor, while its timeline behind the compose window keeps updating. WebBrain took those changes as the page changing under it, and since it checks what lies under the middle of an element to be sure it still has the right one, the bubble also made it lose the editor: it refused to type, and choosing Retry met the same bubble. That click now counts as part of the typing, and from then on the typing is checked against the editor itself rather than against what covers its middle. Each step puts the focus back in the editor, and the text is sent only to the editor itself; if the page moves the focus elsewhere just before the text goes out, nothing is typed. This also closes an older gap on pages where nothing covers the editor: if a page moved the focus into an iframe just before WebBrain's text went out, the text was typed into that iframe. When the bubble is still there from an earlier attempt and the editor still has the focus, WebBrain types into it, or presses keys in it, without clicking it again; clicking a control whose middle is covered is still refused. Your own clicking or typing, a changed reply setting, a replaced editor or a compose window that stops accepting input still stop it before any text is sent. Separately, the agent then tried the selector `[data-testid="tweetTextarea_0"]`, which on X names both the compose box and the hidden one on the timeline behind it. That can never be typed into safely, but because the timeline kept updating, each such decision was thrown away as out of date without an answer, the agent saw the same page and decided the same again, and after five rounds the run blamed the page. Such a call now answers for itself, saying the selector matches more than one element and to use the box the agent observed, and it no longer counts as the page changing. Still not fixed: in Chrome, typing by a selector that names only the compose box is refused while the timeline keeps updating, because finding the box by selector scrolls the page before the call has been checked. That refusal now says that the page changed and to type into the box the agent observed, which works, instead of saying that WebBrain could not attach to the tab, which usually means DevTools is open. The click and the retry without a click are Chrome's way of typing; the selector answer and typing into a focused editor whose middle is covered apply in Chrome and Firefox.
+- When the model provider rate-limits WebBrain (HTTP 429, or Anthropic's 529 "overloaded"), the step is now waited out and retried up to three times (about 5, 15 and 30 seconds, or longer if the provider asks), also when the limit arrives in the middle of a response, as OpenRouter and WebBrain Cloud report it, and for Anthropic (including Vertex), Azure OpenAI, AWS Bedrock and llama.cpp, whose limits ended Act runs at once. An answer you already saw part of is never generated again. A message such as "Rate limit exceeded" is no longer mistaken for an over-long conversation, so WebBrain no longer trims your conversation and asks you to start a new one. Older context is trimmed only when one request alone exceeds the provider's per-minute token limit, and then right away and only once; if the provider does not state its limit, one shortened retry is tried, and the conversation is shortened only if that retry succeeds. Each wait is lengthened at random by up to 20% so several runs do not retry at the same moment, and never comes sooner than the provider asks. An OpenAI "insufficient_quota" billing error now fails at once instead of being retried, and traces label rate limits as rate limiting even when the message mentions a quota.
+- The local vision fallback now also runs when an OpenAI-compatible provider such as Ollama or LM Studio rejects a screenshot as unsupported. The rejection's status was read from the wrong field, so the fallback never started.
+- Chat sites: a message is no longer sent to whoever's chat is open just because an e-mail address appears in that chat's earlier messages. When a chat showed no contact name at the top, WebBrain took such an address for the recipient; now it stops and says it cannot tell who the chat is with. An address shown in the conversation's own header, as in help-desk and CRM conversations, still identifies the recipient, while an address in the header's pinned text does not, and mail compose windows read their To, Cc and Bcc addresses as before. In Google Chat inside Gmail, an address mentioned in the chat is never taken as the recipient either: WebBrain stops before sending there, since nothing on the page reliably tells the chat's name from the names in its messages, while a Gmail compose window open over the Chat view still sends to its To, Cc and Bcc addresses.
+- Long text fields: WebBrain no longer replaces a field's text with the shortened copy it was shown, such as the first 60 characters followed by "...", which deleted everything after that point. The write is refused before anything is typed, also in embedded frames, and WebBrain is told to read the full text first. Complete new text and additions are typed as before, and a field whose own text contains a "[… truncated …]" note, such as a pasted log, can still be edited.
+- Choosing an option in a dropdown: the hint now suggests pressing the down arrow and then Enter, one key at a time, which the key tool supports, instead of typing the option's first letter in a form the key tool always rejects.
+- Reading Google pages while signed in: your Google account's name, e-mail address and profile photo from Google's account button are no longer shown to the AI, in the page structure, click, hover, drag and scroll results, element and link lists, text-click candidates, covering-overlay messages, page media or screenshot element lists. The button is still there, called "Google account", and the signed-out "Sign in" link keeps its name. Account links that belong to the page itself, such as on your Google Account pages or in a security-alert e-mail, and e-mail addresses on the page, such as a business's contact address, are unchanged.
+- Progress list: a row can no longer be marked as acted on when the click or typing behind it was blocked and never sent; the agent is told to retry, or to check the page and record what it shows. Actions that really happened before you corrected the task mid-run, or in an earlier run, still count.
+- Collecting details from a list of named people or pages without changing anything can now finish successfully. Before, each item demanded a page-changing action that a read-only task never makes.
+- Repeated tasks such as following 40 listed profiles no longer show each profile twice on the progress list: clicks WebBrain records itself now fill the planned rows.
+- When the model calls a tool it no longer has, such as the retired screenshot tool, or click in Ask mode, it is told what to use instead (inspect_viewport, or asking you to type /screenshot --full-page), and repeated attempts stop the run after ten tries without hiding a genuinely stuck step. Missing tool arguments are now named as missing.
+- When a task needs a value or a choice from you, the agent now asks with a question card and carries on after your answer, instead of ending the task and treating your reply as a new request.
+- With Research escalation turned off, a question about who should receive a message, or a request to switch recipient, was refused as invalid before it reached you. It now works whether or not Research escalation is on.
+- With Research escalation on, Ask mode was told to ask clarifying questions with a tool it does not have, so those questions failed. Ask now puts a missing detail, such as dates or a budget, into its answer.
+- After a question timed out, your next message could end at the first blocked step with "Please answer it and try again", with nothing left to answer. WebBrain now asks the question again first; an answer picked automatically after a timeout still never counts as your decision.
+- Scheduling a task now says which page it runs on and how often it repeats in plain units ("every 30 days"). An interval of 28 to 31 days is described as fixed, not monthly, since it drifts against calendar dates, and a requested time more than 7 days away is reported as over the limit instead of quietly being scheduled earlier.
+- A scheduled task, recurring or one-time, no longer schedules itself again when it runs, for example a recurring task whose instructions say "every 5 minutes" or a reminder such as "In 30 minutes, remind me to take the pizza out", and no longer fails because it did not. A one-time task can still set up a new schedule when it explicitly asks for one, such as "on Monday at 9, start an hourly check".
+- A recurring scheduled task now pauses, with the reason shown, when a run ends with a question only you can answer, or after three failed runs with no successful run in between, instead of running again and again. Resuming a task you paused keeps its next run time, or runs it about a minute later if that time has passed; tasks WebBrain paused restart their interval when you resume them, and paused tasks no longer show a "Next" time.
+- When WebBrain reads another page in the background, it now says so accurately: a quick fetch opens no tab, a full-page read may briefly show a temporary tab in the tab strip that closes by itself, and your current tab never changes. Requests to open or show a page are steered to real navigation.
+- Shared runs and diagnostics keep their internal IDs intact. The WebBrain Cloud privacy filter sometimes masked an ID whose timestamp looked like a payment card number, which broke the links between a run's records, including tool calls from local models. New IDs use a compact timestamp; existing IDs keep working.
+- "Summarize this page" now keeps reading long pages to the end before summarizing, and says which part it covered if it had to stop early.
+- The navigation tool's description now says correctly that a page's "Leave site?" warning may be confirmed automatically and that not every unsaved edit is detected, so the agent saves work first when it needs it.
+- When a task ends, a sidebar search box that names itself only by its placeholder, such as Mastodon's with its icon-only button, no longer counts as a form left unsent and no longer blocks finishing twice. A model reads what the field is for, in any language; a box holding typed text, a comment or message box, or a people picker still counts.
+- Strict secret handling: a password or code WebBrain filled into a sensitive field, including one typed into the focused field or an embedded frame, no longer ends up in the agent's scratchpad or progress list, which are sent with every later request and saved with the conversation. It is replaced with "[redacted credential]", also in notes written before it was typed, after the browser restarts the extension's background worker (including on captcha-protected logins), and under password-like field names, while fields such as page_token, token_count or secretary, the app's own notes, file names and download ids are left alone, and a private Cloud result keeps the password it generated. A short numeric PIN, and a secret you only typed into chat and never had filled into a field, are not recognized.
+ - Verified `type_text` writes now carry their exact clear/append value into the same batch's original field certificates, allowing later known fields to run without accepting unrelated page changes.
+ - Evaluation payloads place batch guidance immediately after the base Act prompt, matching production ordering before Dev guidance, site adapters, and loaded skills while preserving frozen snapshots.
+ - Build batch guidance from the current tab's run provider, and grade proposed batches only after the complete wrapper and all child arguments pass production validation against the evaluated tool surface.
+ - Browser batches use the run's selected provider tier for action limits and continuation rules, and wait briefly for delayed navigation before deciding whether another child can run. Navigation that remains unsettled stops the remaining actions for verification.
+ - Keep each retained browser batch result inside its original untrusted-content boundaries when trimming context. Rejected batches no longer overwrite a native sibling's execution receipt when its call ID resembles a generated batch child ID.
- Mastodon: deleting your own post no longer stops at Mastodon's "Delete post?" confirmation. WebBrain opened the post's "…" menu and chose Delete, and the confirmation that its own click opened was refused as "not inside one identifiable record". When the menu entry was clicked no model had read its caption yet, so WebBrain had not tied the confirmation to the post, and while the confirmation is open Mastodon makes the rest of the page inert, which WebBrain read as the post and your account being hidden. Mastodon's dangerous entries on your own post now count as its deletion by page structure, the post and your account behind the confirmation still count, and Mastodon's own confirm button is recognized in windows narrower than 1175 px, where Mastodon shows no composer beside the timeline. A confirmation that WebBrain's click did not open, another account's post, and anything inert without Mastodon's confirmation open still bind nothing. With Mastodon's confirmation turned off, the dangerous entry is checked as the deletion itself even before its caption is read.
- Ask mode: an answer being written no longer disappears and starts over when you use the page meanwhile. In a WhatsApp trace, typing a draft and clicking in the chat while the answer was written threw the answer away twice and wrote it again each time, and the answer that finally stayed, written after you stopped, was the shortest. Scrolling, selecting, clicking and typing on the page, and the page's changes from them, now leave the answer as it is: it is about the page as you asked about it, and the run ends without waiting for you to stop typing. Navigating the page to another address still starts the answer over.
- Posting on another site after a correction: after a Mastodon post, "ok now on X" no longer leaves WebBrain going back and forth between the two sites, typing the X post again each time. It counted X as the same platform as Mastodon, because it reads account names only on X and Bluesky, and asked to find the Mastodon post on X itself, which can never happen. The site a post was made on now names its platform when no account name was read, and a post on another site goes ahead once a page has been read since the correction, provided the task made no earlier post on that site. What the task attempted is saved with the conversation, and just before each action that may post or submit something, so this still holds when the task continues after WebBrain restarted, and a post already sent on X under the correction is not sent again by a later run of the task. When the task did post on that site before, or WebBrain has no full record of its earlier attempts, it stops once and says so, instead of searching for a post it cannot find. A search, a settings save or consent click on X, a click that sent nothing or a form the page rejected is not such a post; a click that Stop interrupted after it was sent counts. On the other hosts and clients of X and Bluesky, such as X Pro, whose Post buttons WebBrain does not recognize, anything sent that may have been a post counts as one, so a post from X Pro is not repeated on x.com; this includes a Post button whose caption no model read in time, which looked like a harmless button, while Enter in the post editor there edits the draft and is not a post. If that record cannot be saved just before a possible post on X or Bluesky, the post is not sent and WebBrain says why, as it already does when a run's recovery checkpoint cannot be saved. x.com and twitter.com are one platform.
diff --cc package.json
index cfeddd14c,ffd6a34ad..b15397469
--- a/package.json
+++ b/package.json
@@@ -91,14 -94,14 +94,14 @@@
"test:quality:whatsapp": "node test/quality/whatsapp-contact-matrix.mjs",
"test:chat-draft-recovery": "node --test test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs && node test/quality/native-chat-presubmit-mv3.mjs",
"test:upload-owner": "node --test test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs",
- "test:shard:quick": "npm run test:cms && npm run test:markdown && npm run test:generative-media && npm run test:systemone && npm run test:systemone:fast && node --test test/browser-dialogs.mjs test/capsolver-cloud-broker.mjs test/captcha-providers.mjs test/captcha-weighted-fallback.mjs test/captcha-hcaptcha-providers.mjs test/captcha-native-providers.mjs test/captcha-runtime-policy.mjs test/captcha-callback-bridge.mjs test/captcha-bridge-registration.mjs test/captcha-aws-recovery.mjs test/captcha-documented-contracts.mjs test/huggingface-signup-recovery.mjs test/trace-full-export.mjs test/feedback-traces.mjs && npm run test:firefox-bidi && npm run test:billing-notice && npm run test:compass-quota && npm run test:provider-limits && npm run test:provider-catalog && npm run test:provider-instances:ui && npm run test:openrouter-capabilities && npm run test:anthropic && npm run test:accessibility-tree-benchmark && npm run test:toolbar-guard && npm run test:cloud-bridge-approval && npm run test:discord && npm run test:pdf-read && npm run test:pdf-selection && npm run test:social-contract && npm run test:safesocial && npm run test:build-unpacked && npm run test:attachment-drop && npm run test:workflow-editor && node --test test/profile-sync-stats.mjs && node --test test/memcode-recall.mjs",
- "test:shard:runtime-unit": "node --test test/skill-download-wait.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-click-guard.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/completion-current-execution-evidence.mjs test/video-upload-attachment.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/lifecycle-planner-digest.mjs test/lifecycle-steering-latency.mjs test/lifecycle-steering-restart.mjs test/lifecycle-vision-fallback.mjs test/delivery-click-locks.mjs test/guards-steering-receipts.mjs test/terminal-user-messages.mjs test/improver-providers.mjs test/improver-providers-agent.mjs test/improver-guards-ledger.mjs test/improver-guards-tools.mjs test/improver-clarify.mjs test/improver-clarify-scheduler.mjs test/improver-misc.mjs test/improver-forms.mjs test/improver-forms-strict-secrets.mjs test/improver-content-press-keys-hint.mjs",
+ "test:shard:quick": "npm run test:cms && npm run test:markdown && npm run test:generative-media && npm run test:systemone && npm run test:systemone:fast && node --test test/browser-dialogs.mjs test/capsolver-cloud-broker.mjs test/captcha-providers.mjs test/captcha-weighted-fallback.mjs test/captcha-hcaptcha-providers.mjs test/captcha-native-providers.mjs test/captcha-runtime-policy.mjs test/captcha-callback-bridge.mjs test/captcha-bridge-registration.mjs test/captcha-aws-recovery.mjs test/captcha-documented-contracts.mjs test/huggingface-signup-recovery.mjs test/trace-full-export.mjs test/feedback-traces.mjs && npm run test:firefox-bidi && npm run test:billing-notice && npm run test:compass-quota && npm run test:provider-limits && npm run test:provider-catalog && npm run test:provider-instances:ui && npm run test:openrouter-capabilities && npm run test:anthropic && npm run test:browser-batch && npm run test:accessibility-tree-benchmark && npm run test:toolbar-guard && npm run test:cloud-bridge-approval && npm run test:discord && npm run test:pdf-read && npm run test:pdf-selection && npm run test:social-contract && npm run test:safesocial && npm run test:build-unpacked && npm run test:attachment-drop && npm run test:workflow-editor && node --test test/profile-sync-stats.mjs && node --test test/memcode-recall.mjs",
- "test:shard:runtime-unit": "node --test test/skill-download-wait.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-click-guard.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/completion-current-execution-evidence.mjs test/video-upload-attachment.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/lifecycle-planner-digest.mjs test/lifecycle-steering-latency.mjs test/lifecycle-steering-restart.mjs test/lifecycle-vision-fallback.mjs test/delivery-click-locks.mjs test/guards-steering-receipts.mjs test/terminal-user-messages.mjs && npm run test:plan-notifications",
- "test:shard:browser-a": "node test/bot-memory-dom.mjs && node test/bot-memory-click-dom.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/native-button-preparation.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/page-monitor-ui.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs test/delivery-cdp-input.mjs test/delivery-click-ax-response-loss.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-dispatch-boundary.mjs test/delivery-stop-compound.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/submit-probe-readings.mjs",
++ "test:shard:runtime-unit": "node --test test/skill-download-wait.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-click-guard.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/completion-current-execution-evidence.mjs test/video-upload-attachment.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/lifecycle-planner-digest.mjs test/lifecycle-steering-latency.mjs test/lifecycle-steering-restart.mjs test/lifecycle-vision-fallback.mjs test/delivery-click-locks.mjs test/guards-steering-receipts.mjs test/terminal-user-messages.mjs test/improver-providers.mjs test/improver-providers-agent.mjs test/improver-guards-ledger.mjs test/improver-guards-tools.mjs test/improver-clarify.mjs test/improver-clarify-scheduler.mjs test/improver-misc.mjs test/improver-forms.mjs test/improver-forms-strict-secrets.mjs test/improver-content-press-keys-hint.mjs && npm run test:plan-notifications",
+ "test:shard:browser-a": "node test/bot-memory-dom.mjs && node test/bot-memory-click-dom.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/native-button-preparation.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs test/delivery-cdp-input.mjs test/delivery-click-ax-response-loss.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-dispatch-boundary.mjs test/delivery-stop-compound.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/submit-probe-readings.mjs test/improver-content-account-chrome.mjs test/improver-content-recipient.mjs test/improver-content-truncated-replacement.mjs test/improver-forms-probe.mjs test/improver-misc-trace-browser.mjs",
- "test:shard:browser-b1": "node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs test/message-control-readings.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-mv3.mjs && node test/quality/ask-person-activity-mv3.mjs && node test/quality/telegram-cold-preparation-mv3.mjs && node test/quality/native-chat-mv3.mjs && node test/quality/native-chat-presubmit-mv3.mjs && node test/quality/cloud-bot-memory-mv3.mjs",
+ "test:shard:browser-b1": "node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs test/message-control-readings.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/integration-mv3.mjs --batch && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-mv3.mjs && node test/quality/ask-person-activity-mv3.mjs && node test/quality/telegram-cold-preparation-mv3.mjs && node test/quality/native-chat-mv3.mjs && node test/quality/native-chat-presubmit-mv3.mjs && node test/quality/cloud-bot-memory-mv3.mjs",
"test:shard:browser-b2": "node test/quality/whatsapp-contact-matrix.mjs && node test/quality/pdf-detection-mv3.mjs && node test/quality/download-upload-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs && node test/quality/release-review-world-mv3.mjs && node test/quality/downloaded-file-saved-bytes-mv3.mjs && node test/quality/file-upload-accept-mv3.mjs && node test/quality/bulk-resume-mv3.mjs && node test/quality/shared-action-guards-mv3.mjs && node test/quality/video-upload-attachment-mv3.mjs",
- "test:shard:browser-c": "node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs --menu-read && node test/quality/mastodon-delete-confirmation-mv3.mjs --vague && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-mv3.mjs && node test/quality/open-chat-recipients-mv3.mjs && node test/quality/correction-cross-site-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs && node test/quality/dropdown-menu-matrix.mjs && node test/quality/mastodon-deletion-navigation-mv3.mjs && node test/quality/semantic-navigation-matrix.mjs && node test/quality/workflow-replay-mv3.mjs && node test/quality/generative-media-mv3.mjs && node test/quality/cdp-worker-restart-mv3.mjs && node test/quality/steering-worker-restart-mv3.mjs",
+ "test:shard:browser-c": "node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs --menu-read && node test/quality/mastodon-delete-confirmation-mv3.mjs --vague && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-mv3.mjs && node test/quality/open-chat-recipients-mv3.mjs && node test/quality/correction-cross-site-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs && node test/quality/dropdown-menu-matrix.mjs && node test/quality/mastodon-deletion-navigation-mv3.mjs && node test/quality/semantic-navigation-matrix.mjs && node test/quality/workflow-replay-mv3.mjs && node test/quality/generative-media-mv3.mjs && node test/quality/cdp-worker-restart-mv3.mjs && node test/quality/steering-worker-restart-mv3.mjs",
"test:shard:tail": "node test/run.js && node test/selection-scope-restoration.mjs && node scripts/benchmark-offline-relevance.mjs && npm run test:security",
- "test:composer-context": "node --test test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs",
+ "test:composer-context": "node --test test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs",
"test:bot-memory": "node --test test/bot-memory.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs && node test/bot-memory-dom.mjs && node test/quality/cloud-bot-memory-mv3.mjs",
"test:shared-action-guards": "node --test test/typing-preparation-geometry.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/trusted-field-preparation-ownership.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/guards-steering-receipts.mjs && node test/quality/shared-action-guards-mv3.mjs"
},
diff --cc src/chrome/src/agent/agent.js
index 21a3807d9,577d9b0ba..c1176e0b9
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@@ -16,7 -16,7 +16,7 @@@ import { createSystemOneJudge, isSystem
import { SEMANTIC_BATCH_LIMITS, SEMANTIC_DECISION_VERSION, acceptSemanticAnswer, acceptSemanticBatchAnswers, boundedSemanticData, controlEffectCommits, semanticBatchChunks, semanticBatchDecisionMessages, semanticDecisionMessages, semanticQuestion, semanticSystemOneBatchQuestions, semanticSystemOneQuestion, WORKFLOW_STATES } from './semantic-decisions.js';
import { SOCIAL_PLATFORMS, socialPublicationApiPlatform, normalizePublicationContract, resolvePublicationText, publicationProgress, exactPublicationText, publicationMediaMatches, publicationContractMessages, publicationAuditMessages, parsePublicationJson, publicationAuditValidation } from './social-publish-contract.js';
import { mastodonPublicationIntentMessages, normalizeMastodonPublicationIntent, captureNativeMastodonPublication, mastodonPublicationBinding, mastodonPublicationReceipt, mastodonPublicationNavigation } from './mastodon-publication.js';
- import { AGENT_TOOLS, AGENT_TOOL_NAMES, RESERVED_AGENT_TOOL_NAMES, RETIRED_AGENT_TOOL_NAMES, getToolsForMode, SYSTEM_PROMPT_ASK, SYSTEM_PROMPT_ACT, SYSTEM_PROMPT_ACT_COMPACT, SYSTEM_PROMPT_ACT_MID, SYSTEM_PROMPT_GENERATIVE_MEDIA, SYSTEM_PROMPT_DEV_APPENDIX, SYSTEM_PROMPT_WEBMCP_ASK, SYSTEM_PROMPT_WEBMCP_ACT } from './tools.js';
-import { AGENT_TOOLS, AGENT_TOOL_NAMES, RESERVED_AGENT_TOOL_NAMES, getToolsForMode, SYSTEM_PROMPT_BATCHING, SYSTEM_PROMPT_ASK, SYSTEM_PROMPT_ACT, SYSTEM_PROMPT_ACT_COMPACT, SYSTEM_PROMPT_ACT_MID, SYSTEM_PROMPT_GENERATIVE_MEDIA, SYSTEM_PROMPT_DEV_APPENDIX, SYSTEM_PROMPT_WEBMCP_ASK, SYSTEM_PROMPT_WEBMCP_ACT } from './tools.js';
++import { AGENT_TOOLS, AGENT_TOOL_NAMES, RESERVED_AGENT_TOOL_NAMES, RETIRED_AGENT_TOOL_NAMES, getToolsForMode, SYSTEM_PROMPT_BATCHING, SYSTEM_PROMPT_ASK, SYSTEM_PROMPT_ACT, SYSTEM_PROMPT_ACT_COMPACT, SYSTEM_PROMPT_ACT_MID, SYSTEM_PROMPT_GENERATIVE_MEDIA, SYSTEM_PROMPT_DEV_APPENDIX, SYSTEM_PROMPT_WEBMCP_ASK, SYSTEM_PROMPT_WEBMCP_ACT } from './tools.js';
import { rejectedCompletionRecovery } from './completion-recovery.js';
import { FailureRecoveryRegistry, modelFailureRecovery } from './failure-recovery.js';
import { validateToolArguments } from './tool-arguments.js';
@@@ -26,8 -27,8 +27,8 @@@ import { chatRecoveryDisplayText, termi
import { isSessionQuotaError, serializeConversationForSession, SESSION_CONVERSATION_BUDGET_BYTES, SESSION_CONVERSATION_RETRY_BUDGET_BYTES } from './conversation-persistence.js';
import { SteeringJournal } from './steering-journal.js';
import { formatErrorMessage } from '../error-format.js';
-import { retryModelCall, retryModelStream } from '../providers/model-retry.js';
+import { isBillingQuotaError, isRateLimitClass, retryModelCall, retryModelStream } from '../providers/model-retry.js';
- import { isQwenConfig } from '../providers/provider-compatibility.js';
+ import { isQwenConfig, preserveToolCallSignature } from '../providers/provider-compatibility.js';
import { aggregateMessageCompletion } from '../message-info.js';
import { handleDoneJson } from './cloud-output.js';
import { applyReadPageWindow, fitReadPageWindowResult, isReadPageWindowResult } from './read-page-window.js';
@@@ -13740,10 -13619,7 +13856,10 @@@ Rules: no prose intro, no conclusion, n
} : {}),
};
const name = call.function?.name || 'unknown_tool';
+ // A call the batch never reached was not sent, and is noted like any
+ // other unsent result; the interrupted call was noted above.
+ if (!active) this._noteProgressActionDispatch(tabId, name, this._toolCallArgs(call), result, false);
- const message = { role: 'tool', tool_call_id: call.id, content: serialize(name, result) };
+ const message = { role: 'tool', tool_call_id: call.id, content: serialize(name, result, call._browserBatch) };
messages.push(message);
notifications.push({ name, args: active?.args || this._toolCallArgs(call), result, message, active });
answered.add(call.id);
@@@ -51840,21 -51204,10 +52042,21 @@@
requestedMaxTokens: streamOpts.maxTokens, recoveryAttempt: streamAttempt - 1,
...Agent._traceMediaCounts(prunedMessages),
}, { messages: prunedMessages, tools: streamOpts.tools || [], runtimeMode: mode });
- return provider.chatStream(prunedMessages, streamOpts);
+ return provider.chatStream(foldBrowserBatchMessages(prunedMessages, { repairPending: true }), streamOpts);
}, {
isAborted: () => this._checkAbort(tabId) || this._hasPendingSteering(tabId),
+ // Reasoning is never shown while it streams (it is kept only with
+ // the finished message), so a rate limit after reasoning alone is
+ // retried like one before the first event, without the failed
+ // attempt's reasoning. Text and tool calls end startup.
+ isOutput: chunk => chunk?.type !== 'reasoning',
onRetry: async ({ error, delayMs, attempt }) => {
+ // An overflow, or a request alone over a per-minute token limit,
+ // never clears by waiting, so it goes straight to the trim below;
+ // a token-limit trial is a single request.
+ if (this._isContextOverflowFailure(error) || (tokenLimitTrial && this._isTokenRateLimit(error))
+ || this._tokenLimitRemedy(error, () => this._requestTokenEstimate(prunedMessages, streamOpts.tools || [])) === 'trim') throw error;
+ if (isRateLimitClass(error)) streamRateLimitRetried = true;
onUpdate('thinking', { step: steps, note: `The model service could not start the response. Retrying (${attempt})…` });
if (runId) await trace.recordLLMRetry(runId, steps, { delayMs, code: this._traceErrorCodeFor(error) });
},
diff --cc src/chrome/src/agent/page-feedback.js
index 14505198f,6d6231624..1b4278279
--- a/src/chrome/src/agent/page-feedback.js
+++ b/src/chrome/src/agent/page-feedback.js
@@@ -1131,12 -1105,10 +1135,17 @@@ export const pageFeedbackMethods =
&& run.frames.get(id)?.id === frame.id);
},
- async _validatePageFeedbackAction(tabId, name, args, state, batchId = null) {
+ // answerOnly: an early check that only answers a target the certificate
+ // cannot bind; any other outcome is left to the call's own validation.
- async _validatePageFeedbackAction(tabId, name, args, state, { answerOnly = false } = {}) {
++ async _validatePageFeedbackAction(tabId, name, args, state, batchId = null, { answerOnly = false } = {}) {
++ // Back-compat: an earlier revision passed { answerOnly } as the 5th arg.
++ if (batchId && typeof batchId === 'object') {
++ answerOnly = !!batchId.answerOnly;
++ batchId = null;
++ }
const run = this._pageFeedbackRuns?.get(tabId);
const binding = state?.actionBinding;
- if (run) { run.actionBindingUnavailable = null; run.actionContextUnverified = false; }
+ if (run) { run.actionBindingUnavailable = null; run.actionBindingUnavailableReason = null; run.actionContextUnverified = false; }
if (!run || !binding || run.modelState !== state || !this._pageFeedbackStateCurrent(tabId, run, state)
|| (run.events.size && !isAutomaticPageFeedback([...run.events.values()]))) return false;
try {
@@@ -1196,18 -1163,6 +1206,18 @@@
} catch { return false; }
},
+ // A typing call's own preparation probes its target before dispatch. A
+ // target the certificate cannot bind at all is answered first and
+ // precisely: a probe of an ambiguous selector could only pick one of its
+ // elements. Anything else is left to the dispatch wrapper.
+ async _pageFeedbackUnbindableResult(tabId, name, args = {}) {
+ const run = this._pageFeedbackRuns?.get(tabId);
+ if (!run || typeof args?.selector !== 'string' || !args.selector.trim() || !this.constructor.STATE_CHANGE_TOOLS?.has(name)
+ || pageFeedbackCallPolicy(name, args, run.modelState, run.latestPage).kind !== 'bound_target') return null;
- if (await this._validatePageFeedbackAction(tabId, name, args, run.modelState, { answerOnly: true }) !== false) return null;
++ if (await this._validatePageFeedbackAction(tabId, name, args, run.modelState, null, { answerOnly: true }) !== false) return null;
+ return run.actionBindingUnavailable === `${name}:${JSON.stringify(args)}` ? actionBindingUnavailableResult(run) : null;
+ },
+
_pageFeedbackBlocksCall(tabId, name, args = {}) {
const run = this._pageFeedbackRuns?.get(tabId);
if (run?.dispatchCall?.expectedModelSnapshot
@@@ -1424,20 -1385,7 +1440,20 @@@
if (retained) for (const call of responseToolCalls) {
const args = JSON.parse(call.function.arguments);
if (pageFeedbackCallPolicy(call.function.name, args, state, page, events).kind === 'bound_target'
- && await this._validatePageFeedbackAction(tabId, call.function.name, args, state) !== true) {
+ && await this._validatePageFeedbackAction(tabId, call.function.name, args, state, call._browserBatch?.parentId) !== true) {
+ // A target the certificate cannot bind (a selector naming several
+ // elements or none, a ref the observation did not certify, a control
+ // its snapshot does not cover) gets the same answer after these page
+ // updates, and discarding the response would only show the model the
+ // same view to decide again. Keep the call: its own no-dispatch result
+ // (action_binding_unavailable) tells the model why, and the rest of
+ // its batch does not run. If a real change caused it (its element
+ // removed or added), the attached fresh observation shows that. A
+ // changed binding, an unverified action context and user input still
+ // supersede the response.
+ if (run.actionBindingUnavailable === `${call.function.name}:${JSON.stringify(args)}`) {
+ unbindableActionTarget = true; continue;
+ }
unverifiedActionContext = run.actionContextUnverified === true;
retained = false; break;
}
@@@ -1561,9 -1509,11 +1578,9 @@@ export function installPageFeedback(Age
if (run && policy.kind === 'media_resolve') return this._resolvePageFeedbackMedia(tabId, policy.target);
let modelBound = !!run && mutation && policy.kind === 'bound_target';
if (modelBound) {
- const validated = await this._validatePageFeedbackAction(tabId, name, args, modelState);
+ const validated = await this._validatePageFeedbackAction(tabId, name, args, modelState, batchId);
if (validated === false) return run.actionBindingUnavailable === `${name}:${JSON.stringify(args)}`
- ? { success: false, skipped: true, dispatched: false, noDispatch: true, retryable: false,
- errorCode: 'action_binding_unavailable',
- error: 'The exact target could not be bound to the observed action context. Fresh available target/page context will be observed before the next decision; inspect it or read the exact target inventory before trying the action again.' }
+ ? actionBindingUnavailableResult(run)
: run.actionContextUnverified === true
? { ...pageFeedbackPendingResult(), actionContextUnverified: true, errorCode: 'action_context_unverified',
error: 'The requested control had no verified original action context. No action was dispatched; inspect the fresh bounded target observation before choosing another action.' }
diff --cc src/chrome/src/content/page-monitor.js
index 008cf1a9d,8e4cc2e81..18ecb76f6
--- a/src/chrome/src/content/page-monitor.js
+++ b/src/chrome/src/content/page-monitor.js
@@@ -1725,12 -1713,53 +1725,56 @@@
&& (!item.files || (item.files.length === current.files?.length && item.files.every((file, fileIndex) => file === current.files[fileIndex])));
}));
}
+ function sealBrowserBatchInput(owner, params) {
+ const op = owner?.batchInputOperation || owner;
+ const snapshot = modelSnapshots.get(op?.expectedModelSnapshot);
+ if (!op?.batchId || !snapshot || snapshot.until < Date.now() || snapshot.runToken !== runToken
+ || op.batchId !== owner.batchId || op.modelBindingInvalid || op.preparedBinding?.relaxed || authorityChanged(op)
+ || typeof params.batchInputText !== 'string') return false;
+ const current = operationBinding(op);
+ if (!inputContinuationBindingMatches(op, current)) return false;
+ const target = op.preparedBinding.target;
+ if (target.tagName !== 'TEXTAREA' && !(target.tagName === 'INPUT'
+ && !['password', 'file', 'hidden', 'checkbox', 'radio', 'button', 'submit', 'reset', 'image'].includes(target.type))) return false;
+ const originalField = preparedBindingFor(op.preparedBinding).nodes.find(item => item.node === target);
+ const originalValue = originalField && JSON.parse(originalField.value)[12];
+ const expectedValue = params.batchInputClear === true ? params.batchInputText : originalValue + params.batchInputText;
+ if (typeof originalValue !== 'string' || target.value !== expectedValue
+ || (op.batchFinalBinding && !samePreparedBinding(op.batchFinalBinding, current))) return false;
+ // Carry only this verified input's own value into the original certificates.
+ // Names, recipients, form identity, other controls and node identity stay
+ // fixed. A sibling top-level call cannot borrow this batch's continuation.
+ const changed = current.nodes.find(item => item.node === op.preparedBinding.target);
+ if (!changed) return false;
+ snapshot.batchInputs ??= new Map();
+ const proofs = snapshot.batchInputs.get(op.batchId) || new Map();
+ const changedValue = JSON.parse(changed.value);
+ const changedState = changedValue[11] && JSON.parse(changedValue[11]);
+ for (const original of snapshot.targets.values()) {
+ const before = proofs.get(original) || original;
+ // The target's own certificate includes its observed accessible name;
+ // collateral entries may use authored labels instead. Keep that shape.
+ const nodes = before.nodes.map(item => {
+ if (item.node !== changed.node) return item;
+ const value = JSON.parse(item.value);
+ if (!value[11] || !changedState) return item;
+ const state = JSON.parse(value[11]);
+ for (const index of [1, 3, 4, 8, 9]) state[index] = changedState[index];
+ value[11] = JSON.stringify(state);
+ value[12] = changedValue[12];
+ return { ...item, value: JSON.stringify(value) };
+ });
+ proofs.set(original, { ...before, nodes });
+ }
+ snapshot.batchInputs.set(op.batchId, proofs);
+ return true;
+ }
function operationBindingMatches(op, target = op?.preparedBinding?.target) {
- const current = operationBinding(op, target);
- const matches = samePreparedBinding(preparedBindingFor(op?.preparedBinding), current) || inputContinuationBindingMatches(op, current);
+ let current = operationBinding(op, target);
+ const before = preparedBindingFor(op?.preparedBinding);
+ // Keyboard input to the focused field does not depend on the centre hit.
+ if (current && before && target === op?.preparedBinding?.target && keyboardBoundField(op)) current = { ...current, hit: before.hit };
+ const matches = samePreparedBinding(before, current) || inputContinuationBindingMatches(op, current);
if (op?.preparedBinding?.relaxed && (!matches || !relaxedActionability(target, { input: kindFor(op.modelBindingTool || op.tool) === 'input' }))) {
revokeRelaxedGrant(); return false;
}
@@@ -1872,18 -1900,12 +1916,20 @@@
if (!relaxed && pendingDOM?.source === 'user') return { reason: 'pending_feedback' };
const target = modelTarget(params);
if (!target) {
- if (relaxed) { revokeRelaxedGrant(); return { reason: 'target_unresolved' }; }
- return params.ref_id && snapshot.refs.has(params.ref_id) ? {} : { reason: 'target_unresolved' };
+ // A selector naming several elements (for example a composer and its
+ // hidden copy behind a dialog) can never bind; say so, so the model
+ // can use the observed element's ref instead.
+ let ambiguous = false;
+ if (typeof params.selector === 'string' && !params.ref_id && modelActionTools.has(params.tool)) {
+ try { const query = queryOpenTargets(params.selector); ambiguous = query.complete && query.elements.length > 1; } catch {}
+ }
+ const reason = ambiguous ? 'target_ambiguous' : 'target_unresolved';
+ if (relaxed) { revokeRelaxedGrant(); return { reason }; }
+ return !ambiguous && params.ref_id && snapshot.refs.has(params.ref_id) ? {} : { reason };
}
- const before = snapshot.targets.get(target), previous = snapshot.uncertified.get(target);
+ const original = snapshot.targets.get(target);
+ const before = snapshot.batchInputs?.get(params.batchId)?.get(original) || original;
+ const previous = snapshot.uncertified.get(target);
if (!relaxed && !before && !previous) return { reason: 'target_uncovered', certificationFailure: snapshot.captureFailures.get(target) || 'identity_unobserved' };
if (params.ref_id && snapshot.hasRefs && snapshot.refs.get(params.ref_id) !== target) {
if (relaxed) revokeRelaxedGrant();
diff --cc src/chrome/src/providers/openai.js
index 302b21ad1,cfeaca8c6..1099df8c3
--- a/src/chrome/src/providers/openai.js
+++ b/src/chrome/src/providers/openai.js
@@@ -1,6 -1,8 +1,7 @@@
import { BaseLLMProvider } from './base.js';
+ import { openRouterReplayIdentity, openRouterReplayItems, projectOpenRouterReplay, accumulateReasoningDetails } from './openrouter-replay.js';
import { normalizeQwenToolResult, normalizeQwenToolStream } from './qwen-tool-calls.js';
import { normalizeDolphinPromptedResult, normalizeDolphinPromptedStream } from './dolphin-prompted-tools.js';
-import { retryAfterMs } from './model-retry.js';
import { fetchWithFallback } from './fetch-with-fallback.js';
import {
baseModelNameSniffedVision,
diff --cc src/firefox/src/agent/agent.js
index 204273abd,9168060cd..572288824
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@@ -15,7 -15,7 +15,7 @@@ import { SEMANTIC_BATCH_LIMITS, SEMANTI
import { firefoxBidi } from '../bidi/client.js';
import { SOCIAL_PLATFORMS, socialPublicationApiPlatform, normalizePublicationContract, resolvePublicationText, publicationProgress, exactPublicationText, publicationMediaMatches, publicationContractMessages, publicationAuditMessages, parsePublicationJson, publicationAuditValidation } from './social-publish-contract.js';
import { mastodonPublicationIntentMessages, normalizeMastodonPublicationIntent, captureNativeMastodonPublication, mastodonPublicationBinding, mastodonPublicationReceipt, mastodonPublicationNavigation } from './mastodon-publication.js';
- import { AGENT_TOOLS, AGENT_TOOL_NAMES, RESERVED_AGENT_TOOL_NAMES, RETIRED_AGENT_TOOL_NAMES, getToolsForMode, SYSTEM_PROMPT_ASK, SYSTEM_PROMPT_ACT, SYSTEM_PROMPT_ACT_COMPACT, SYSTEM_PROMPT_ACT_MID, SYSTEM_PROMPT_GENERATIVE_MEDIA, SYSTEM_PROMPT_DEV_APPENDIX } from './tools.js';
-import { AGENT_TOOLS, AGENT_TOOL_NAMES, RESERVED_AGENT_TOOL_NAMES, getToolsForMode, SYSTEM_PROMPT_BATCHING, SYSTEM_PROMPT_ASK, SYSTEM_PROMPT_ACT, SYSTEM_PROMPT_ACT_COMPACT, SYSTEM_PROMPT_ACT_MID, SYSTEM_PROMPT_GENERATIVE_MEDIA, SYSTEM_PROMPT_DEV_APPENDIX } from './tools.js';
++import { AGENT_TOOLS, AGENT_TOOL_NAMES, RESERVED_AGENT_TOOL_NAMES, RETIRED_AGENT_TOOL_NAMES, getToolsForMode, SYSTEM_PROMPT_BATCHING, SYSTEM_PROMPT_ASK, SYSTEM_PROMPT_ACT, SYSTEM_PROMPT_ACT_COMPACT, SYSTEM_PROMPT_ACT_MID, SYSTEM_PROMPT_GENERATIVE_MEDIA, SYSTEM_PROMPT_DEV_APPENDIX } from './tools.js';
import { rejectedCompletionRecovery } from './completion-recovery.js';
import { FailureRecoveryRegistry, modelFailureRecovery } from './failure-recovery.js';
import { validateToolArguments } from './tool-arguments.js';
@@@ -25,8 -26,8 +26,8 @@@ import { chatRecoveryDisplayText, termi
import { isSessionQuotaError, serializeConversationForSession, SESSION_CONVERSATION_BUDGET_BYTES, SESSION_CONVERSATION_RETRY_BUDGET_BYTES } from './conversation-persistence.js';
import { SteeringJournal } from './steering-journal.js';
import { formatErrorMessage } from '../error-format.js';
-import { retryModelCall, retryModelStream } from '../providers/model-retry.js';
+import { isBillingQuotaError, isRateLimitClass, retryModelCall, retryModelStream } from '../providers/model-retry.js';
- import { isQwenConfig } from '../providers/provider-compatibility.js';
+ import { isQwenConfig, preserveToolCallSignature } from '../providers/provider-compatibility.js';
import { aggregateMessageCompletion } from '../message-info.js';
import { handleDoneJson } from './cloud-output.js';
import { applyReadPageWindow, fitReadPageWindowResult, isReadPageWindowResult } from './read-page-window.js';
@@@ -12307,10 -12268,7 +12423,10 @@@ Rules: no prose intro, no conclusion, n
} : {}),
};
const name = call.function?.name || 'unknown_tool';
+ // A call the batch never reached was not sent, and is noted like any
+ // other unsent result; the interrupted call was noted above.
+ if (!active) this._noteProgressActionDispatch(tabId, name, this._toolCallArgs(call), result, false);
- const message = { role: 'tool', tool_call_id: call.id, content: serialize(name, result) };
+ const message = { role: 'tool', tool_call_id: call.id, content: serialize(name, result, call._browserBatch) };
messages.push(message);
notifications.push({ name, args: active?.args || this._toolCallArgs(call), result, message, active });
answered.add(call.id);
@@@ -43823,21 -43308,10 +44024,21 @@@
requestedMaxTokens: streamOpts.maxTokens, recoveryAttempt: streamAttempt - 1,
...Agent._traceMediaCounts(prunedMessages),
}, { messages: prunedMessages, tools: streamOpts.tools || [], runtimeMode: mode });
- return provider.chatStream(prunedMessages, streamOpts);
+ return provider.chatStream(foldBrowserBatchMessages(prunedMessages, { repairPending: true }), streamOpts);
}, {
isAborted: () => this._checkAbort(tabId) || this._hasPendingSteering(tabId),
+ // Reasoning is never shown while it streams (it is kept only with
+ // the finished message), so a rate limit after reasoning alone is
+ // retried like one before the first event, without the failed
+ // attempt's reasoning. Text and tool calls end startup.
+ isOutput: chunk => chunk?.type !== 'reasoning',
onRetry: async ({ error, delayMs, attempt }) => {
+ // An overflow, or a request alone over a per-minute token limit,
+ // never clears by waiting, so it goes straight to the trim below;
+ // a token-limit trial is a single request.
+ if (this._isContextOverflowFailure(error) || (tokenLimitTrial && this._isTokenRateLimit(error))
+ || this._tokenLimitRemedy(error, () => this._requestTokenEstimate(prunedMessages, streamOpts.tools || [])) === 'trim') throw error;
+ if (isRateLimitClass(error)) streamRateLimitRetried = true;
onUpdate('thinking', { step: steps, note: `The model service could not start the response. Retrying (${attempt})…` });
if (runId) await trace.recordLLMRetry(runId, steps, { delayMs, code: this._traceErrorCodeFor(error) });
},
diff --cc src/firefox/src/agent/page-feedback.js
index 14505198f,6d6231624..1b4278279
--- a/src/firefox/src/agent/page-feedback.js
+++ b/src/firefox/src/agent/page-feedback.js
@@@ -1131,12 -1105,10 +1135,17 @@@ export const pageFeedbackMethods =
&& run.frames.get(id)?.id === frame.id);
},
- async _validatePageFeedbackAction(tabId, name, args, state, batchId = null) {
+ // answerOnly: an early check that only answers a target the certificate
+ // cannot bind; any other outcome is left to the call's own validation.
- async _validatePageFeedbackAction(tabId, name, args, state, { answerOnly = false } = {}) {
++ async _validatePageFeedbackAction(tabId, name, args, state, batchId = null, { answerOnly = false } = {}) {
++ // Back-compat: an earlier revision passed { answerOnly } as the 5th arg.
++ if (batchId && typeof batchId === 'object') {
++ answerOnly = !!batchId.answerOnly;
++ batchId = null;
++ }
const run = this._pageFeedbackRuns?.get(tabId);
const binding = state?.actionBinding;
- if (run) { run.actionBindingUnavailable = null; run.actionContextUnverified = false; }
+ if (run) { run.actionBindingUnavailable = null; run.actionBindingUnavailableReason = null; run.actionContextUnverified = false; }
if (!run || !binding || run.modelState !== state || !this._pageFeedbackStateCurrent(tabId, run, state)
|| (run.events.size && !isAutomaticPageFeedback([...run.events.values()]))) return false;
try {
@@@ -1196,18 -1163,6 +1206,18 @@@
} catch { return false; }
},
+ // A typing call's own preparation probes its target before dispatch. A
+ // target the certificate cannot bind at all is answered first and
+ // precisely: a probe of an ambiguous selector could only pick one of its
+ // elements. Anything else is left to the dispatch wrapper.
+ async _pageFeedbackUnbindableResult(tabId, name, args = {}) {
+ const run = this._pageFeedbackRuns?.get(tabId);
+ if (!run || typeof args?.selector !== 'string' || !args.selector.trim() || !this.constructor.STATE_CHANGE_TOOLS?.has(name)
+ || pageFeedbackCallPolicy(name, args, run.modelState, run.latestPage).kind !== 'bound_target') return null;
- if (await this._validatePageFeedbackAction(tabId, name, args, run.modelState, { answerOnly: true }) !== false) return null;
++ if (await this._validatePageFeedbackAction(tabId, name, args, run.modelState, null, { answerOnly: true }) !== false) return null;
+ return run.actionBindingUnavailable === `${name}:${JSON.stringify(args)}` ? actionBindingUnavailableResult(run) : null;
+ },
+
_pageFeedbackBlocksCall(tabId, name, args = {}) {
const run = this._pageFeedbackRuns?.get(tabId);
if (run?.dispatchCall?.expectedModelSnapshot
@@@ -1424,20 -1385,7 +1440,20 @@@
if (retained) for (const call of responseToolCalls) {
const args = JSON.parse(call.function.arguments);
if (pageFeedbackCallPolicy(call.function.name, args, state, page, events).kind === 'bound_target'
- && await this._validatePageFeedbackAction(tabId, call.function.name, args, state) !== true) {
+ && await this._validatePageFeedbackAction(tabId, call.function.name, args, state, call._browserBatch?.parentId) !== true) {
+ // A target the certificate cannot bind (a selector naming several
+ // elements or none, a ref the observation did not certify, a control
+ // its snapshot does not cover) gets the same answer after these page
+ // updates, and discarding the response would only show the model the
+ // same view to decide again. Keep the call: its own no-dispatch result
+ // (action_binding_unavailable) tells the model why, and the rest of
+ // its batch does not run. If a real change caused it (its element
+ // removed or added), the attached fresh observation shows that. A
+ // changed binding, an unverified action context and user input still
+ // supersede the response.
+ if (run.actionBindingUnavailable === `${call.function.name}:${JSON.stringify(args)}`) {
+ unbindableActionTarget = true; continue;
+ }
unverifiedActionContext = run.actionContextUnverified === true;
retained = false; break;
}
@@@ -1561,9 -1509,11 +1578,9 @@@ export function installPageFeedback(Age
if (run && policy.kind === 'media_resolve') return this._resolvePageFeedbackMedia(tabId, policy.target);
let modelBound = !!run && mutation && policy.kind === 'bound_target';
if (modelBound) {
- const validated = await this._validatePageFeedbackAction(tabId, name, args, modelState);
+ const validated = await this._validatePageFeedbackAction(tabId, name, args, modelState, batchId);
if (validated === false) return run.actionBindingUnavailable === `${name}:${JSON.stringify(args)}`
- ? { success: false, skipped: true, dispatched: false, noDispatch: true, retryable: false,
- errorCode: 'action_binding_unavailable',
- error: 'The exact target could not be bound to the observed action context. Fresh available target/page context will be observed before the next decision; inspect it or read the exact target inventory before trying the action again.' }
+ ? actionBindingUnavailableResult(run)
: run.actionContextUnverified === true
? { ...pageFeedbackPendingResult(), actionContextUnverified: true, errorCode: 'action_context_unverified',
error: 'The requested control had no verified original action context. No action was dispatched; inspect the fresh bounded target observation before choosing another action.' }
diff --cc src/firefox/src/content/page-monitor.js
index 008cf1a9d,8e4cc2e81..18ecb76f6
--- a/src/firefox/src/content/page-monitor.js
+++ b/src/firefox/src/content/page-monitor.js
@@@ -1725,12 -1713,53 +1725,56 @@@
&& (!item.files || (item.files.length === current.files?.length && item.files.every((file, fileIndex) => file === current.files[fileIndex])));
}));
}
+ function sealBrowserBatchInput(owner, params) {
+ const op = owner?.batchInputOperation || owner;
+ const snapshot = modelSnapshots.get(op?.expectedModelSnapshot);
+ if (!op?.batchId || !snapshot || snapshot.until < Date.now() || snapshot.runToken !== runToken
+ || op.batchId !== owner.batchId || op.modelBindingInvalid || op.preparedBinding?.relaxed || authorityChanged(op)
+ || typeof params.batchInputText !== 'string') return false;
+ const current = operationBinding(op);
+ if (!inputContinuationBindingMatches(op, current)) return false;
+ const target = op.preparedBinding.target;
+ if (target.tagName !== 'TEXTAREA' && !(target.tagName === 'INPUT'
+ && !['password', 'file', 'hidden', 'checkbox', 'radio', 'button', 'submit', 'reset', 'image'].includes(target.type))) return false;
+ const originalField = preparedBindingFor(op.preparedBinding).nodes.find(item => item.node === target);
+ const originalValue = originalField && JSON.parse(originalField.value)[12];
+ const expectedValue = params.batchInputClear === true ? params.batchInputText : originalValue + params.batchInputText;
+ if (typeof originalValue !== 'string' || target.value !== expectedValue
+ || (op.batchFinalBinding && !samePreparedBinding(op.batchFinalBinding, current))) return false;
+ // Carry only this verified input's own value into the original certificates.
+ // Names, recipients, form identity, other controls and node identity stay
+ // fixed. A sibling top-level call cannot borrow this batch's continuation.
+ const changed = current.nodes.find(item => item.node === op.preparedBinding.target);
+ if (!changed) return false;
+ snapshot.batchInputs ??= new Map();
+ const proofs = snapshot.batchInputs.get(op.batchId) || new Map();
+ const changedValue = JSON.parse(changed.value);
+ const changedState = changedValue[11] && JSON.parse(changedValue[11]);
+ for (const original of snapshot.targets.values()) {
+ const before = proofs.get(original) || original;
+ // The target's own certificate includes its observed accessible name;
+ // collateral entries may use authored labels instead. Keep that shape.
+ const nodes = before.nodes.map(item => {
+ if (item.node !== changed.node) return item;
+ const value = JSON.parse(item.value);
+ if (!value[11] || !changedState) return item;
+ const state = JSON.parse(value[11]);
+ for (const index of [1, 3, 4, 8, 9]) state[index] = changedState[index];
+ value[11] = JSON.stringify(state);
+ value[12] = changedValue[12];
+ return { ...item, value: JSON.stringify(value) };
+ });
+ proofs.set(original, { ...before, nodes });
+ }
+ snapshot.batchInputs.set(op.batchId, proofs);
+ return true;
+ }
function operationBindingMatches(op, target = op?.preparedBinding?.target) {
- const current = operationBinding(op, target);
- const matches = samePreparedBinding(preparedBindingFor(op?.preparedBinding), current) || inputContinuationBindingMatches(op, current);
+ let current = operationBinding(op, target);
+ const before = preparedBindingFor(op?.preparedBinding);
+ // Keyboard input to the focused field does not depend on the centre hit.
+ if (current && before && target === op?.preparedBinding?.target && keyboardBoundField(op)) current = { ...current, hit: before.hit };
+ const matches = samePreparedBinding(before, current) || inputContinuationBindingMatches(op, current);
if (op?.preparedBinding?.relaxed && (!matches || !relaxedActionability(target, { input: kindFor(op.modelBindingTool || op.tool) === 'input' }))) {
revokeRelaxedGrant(); return false;
}
@@@ -1872,18 -1900,12 +1916,20 @@@
if (!relaxed && pendingDOM?.source === 'user') return { reason: 'pending_feedback' };
const target = modelTarget(params);
if (!target) {
- if (relaxed) { revokeRelaxedGrant(); return { reason: 'target_unresolved' }; }
- return params.ref_id && snapshot.refs.has(params.ref_id) ? {} : { reason: 'target_unresolved' };
+ // A selector naming several elements (for example a composer and its
+ // hidden copy behind a dialog) can never bind; say so, so the model
+ // can use the observed element's ref instead.
+ let ambiguous = false;
+ if (typeof params.selector === 'string' && !params.ref_id && modelActionTools.has(params.tool)) {
+ try { const query = queryOpenTargets(params.selector); ambiguous = query.complete && query.elements.length > 1; } catch {}
+ }
+ const reason = ambiguous ? 'target_ambiguous' : 'target_unresolved';
+ if (relaxed) { revokeRelaxedGrant(); return { reason }; }
+ return !ambiguous && params.ref_id && snapshot.refs.has(params.ref_id) ? {} : { reason };
}
- const before = snapshot.targets.get(target), previous = snapshot.uncertified.get(target);
+ const original = snapshot.targets.get(target);
+ const before = snapshot.batchInputs?.get(params.batchId)?.get(original) || original;
+ const previous = snapshot.uncertified.get(target);
if (!relaxed && !before && !previous) return { reason: 'target_uncovered', certificationFailure: snapshot.captureFailures.get(target) || 'identity_unobserved' };
if (params.ref_id && snapshot.hasRefs && snapshot.refs.get(params.ref_id) !== target) {
if (relaxed) revokeRelaxedGrant();
diff --cc src/firefox/src/providers/openai.js
index 2b9274734,ef74bf9d3..069729782
--- a/src/firefox/src/providers/openai.js
+++ b/src/firefox/src/providers/openai.js
@@@ -1,6 -1,8 +1,7 @@@
import { BaseLLMProvider } from './base.js';
+ import { openRouterReplayIdentity, openRouterReplayItems, projectOpenRouterReplay, accumulateReasoningDetails } from './openrouter-replay.js';
import { normalizeQwenToolResult, normalizeQwenToolStream } from './qwen-tool-calls.js';
import { normalizeDolphinPromptedResult, normalizeDolphinPromptedStream } from './dolphin-prompted-tools.js';
-import { retryAfterMs } from './model-retry.js';
import { fetchWithTimeout } from './fetch-timeout.js';
import {
baseModelNameSniffedVision,