Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Read continue turns, carousel order and later-outcome notes without word lists
Claude8b239f4cf05a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d13d428d7..599c9a1a4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -31,6 +31,9 @@ This changelog was generated from the repository Git history and release tags. V- Deleting something your request does not point to exactly ("remove the first item", or a post you describe without its link) no longer ends in a refusal that no answer could fix. WebBrain asks on its own card, "Delete this item on <site>?", showing the item as the page shows it and the site's own confirmation question when there is one, and deletes it only after you click Delete, including through that site confirmation; Don't delete keeps it, and you are not asked about it again in the same task. Toolbar, bulk and repeated deletions are still refused.- Whether your request asks to delete an item, whether a correction asks to delete the earlier post first, and whether you said not to send a message are now read by a model in any language, instead of by word lists in a few languages. The decision model answers when it is turned on in settings; otherwise the active model answers and must quote your request. When neither is sure, WebBrain asks you on its card or does nothing; a request that says not to delete or send something is refused without a card.- The text of a direct message you ask WebBrain to send on X is now read from your request by the model, in any language, instead of being cut out by lists of command verbs, negations and conjunctions. A long message is copied exactly from your request between the first and last words the model quotes, so it is no longer shortened to an excerpt.+- Replying "devam et", "続けて", "merci" or any other short "continue" or "thanks" while a task is under way in Act mode now keeps that task, its progress list and its approved plan, in any language; before, only a list of English words did. A model reads short replies once when they arrive; anything it is not sure about is treated as a new request, as before.+- Asking to go through an Instagram carousel from the last slide to the first now works in any language; before, only a few English and Turkish words did, and a request that merely contained the word "reverse" (for example in a caption it asked to record) scanned backwards.+- The note "Future upvotes and moderation outcomes remain unverified" after a published post now appears whenever your request expected votes or posts not being removed, in any language, and no longer appears just because a request mentions upvotes. The model that checks the finished task answers this in the same check, or the decision model when it checked the task, so it never adds a call to your chat model.- A message your request did not clearly ask to send, or did not say who should get, is no longer blocked with an instruction to ask you that no answer could satisfy. The same "Send to …?" card now shows the message text and why WebBrain is asking. A correction you send while either card is open now applies the correction instead of stopping the run.## [40.3.0] - 2026-10-12diff --git a/docs/architecture.md b/docs/architecture.mdindex 0d82b27ff..d626fe2c7 100644--- a/docs/architecture.md+++ b/docs/architecture.md@@ -764,10 +764,24 @@ every caller treats no answer as "ask the user" or "do nothing". Identicalquestions are answered once. Stop or a correction during a decision cancelsit. The questions are: does the request ask to delete this item; does acorrection ask to delete the earlier post first; does the request say not to-send this message. Consent itself never comes from reading words: who receives-a message and whether an unclear deletion proceeds are answered on WebBrain's-own cards with fixed choices, and a question the model asks, and whatever the-user answers to it, approves neither.+send this message; and does a short Act turn sent after an earlier task only+continue it or acknowledge it. That last answer is read once, when the turn+arrives, and stored on the turn, so the task anchor, the progress ledger's+scope and an approved plan read it without words. The Continue command is a+continuation by construction; long turns, Ask turns, first turns and turns+without a sure answer are new requests. A carousel scan asks whether the+request wants the slides from last to first; no sure answer is the usual+order. Consent itself never comes from reading words: who receives a message+and whether an unclear deletion proceeds are answered on WebBrain's own cards+with fixed choices, and a question the model asks, and whatever the user+answers to it, approves neither.++Whether a request also expects something no run can verify, such as votes or+moderators keeping a post up, is read by whoever verified the completion: the+active model's completion judge answers it in the same request as its verdict,+and after a decision-model verdict the decision model is asked. Nothing else is+called for it, and only a clear answer adds the note that publication was+verified while later votes and moderation remain unverified.Requested field values (a message or post body, release notes, a title) comefrom the intent model too. A short value is returned as is; a long one isdiff --git a/package.json b/package.jsonindex b98ce74ea..da2d1b2aa 100644--- a/package.json+++ b/package.json@@ -59,7 +59,7 @@"benchmark:relevance": "node scripts/benchmark-offline-relevance.mjs --verbose","test:social-contract": "node --test test/social-publish-contract.mjs test/publication-quote-markup.mjs","test:social-contract:dom": "node test/social-publish-contract-dom.mjs",- "test:runtime-lifecycle": "node test/bot-memory-dom.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-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/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/lifecycle-steering-restart.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-anchors.mjs test/completion-current-execution-evidence.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/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-vision-fallback.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/guards-steering-receipts.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/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/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.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 && node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.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/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 && 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/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-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:runtime-lifecycle": "node test/bot-memory-dom.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-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/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/lifecycle-steering-restart.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-anchors.mjs test/user-turn-kind.mjs test/completion-current-execution-evidence.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/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-vision-fallback.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/guards-steering-receipts.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/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/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.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 && node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.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/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 && 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/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-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:page-feedback": "node --test 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/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/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-passive-progress.mjs test/media-download-binding.mjs test/media-download-capture-integration.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/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/delivery-click-ax-response-loss.mjs test/delivery-stop-compound.mjs test/delivery-cdp-input.mjs test/delivery-click-locks.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-dispatch-boundary.mjs && node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs","test:chat-steering": "node --test test/chat-steering.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/lifecycle-steering-latency.mjs test/lifecycle-steering-restart.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs","test:rich-text-dom": "node test/ui-content-lifecycle.mjs --dom",@@ -91,7 +91,7 @@"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/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/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-anchors.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:shard:runtime-unit": "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/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-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: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/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.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:shard:browser-b1": "node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.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/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",diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex d7219f0c2..bc3298bd2 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -7134,9 +7134,10 @@ export class Agent extends LoopDetector {* and sure; otherwise the active model answers with a quoted reason. Returns* { choice, evidence, source } where choice is null when no sure answer was* available; callers then ask the user or do not proceed. Identical- * questions are answered once.+ * questions are answered once. `mainModel: false` asks the decision model+ * only, for a note that is not worth a call to the active model.*/- async _semanticDecision(tabId, kind, { request = '', page = {} } = {}, { provider = this._activeProvider(tabId), signal = null } = {}) {+ async _semanticDecision(tabId, kind, { request = '', page = {} } = {}, { provider = this._activeProvider(tabId), signal = null, mainModel = true } = {}) {const spec = semanticQuestion(kind);const trusted = String(request ?? '').slice(0, 6000);const data = boundedSemanticData(page);@@ -7169,7 +7170,7 @@ export class Agent extends LoopDetector {if (this._isCostAllowanceError(error) || this._checkAbort(tabId)) throw error;this.recordSystemOneVerdict(tabId, { decision: 'fallback', reason: `${kind}_${systemOneFailureReason(error)}` }, context);}- if (!provider?.chat || this._checkAbort(tabId)) return { choice: null, evidence: '', source: 'unavailable' };+ if (!mainModel || !provider?.chat || this._checkAbort(tabId)) return { choice: null, evidence: '', source: 'unavailable' };try {const messages = semanticDecisionMessages(kind, trusted, data, text => this._wrapUntrusted('read_page', text));const response = await withCompletionTimeout(async completionSignal => {@@ -21553,9 +21554,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (steered) return steered;const clarification = this._plannerClarificationTaskBinding(messages, i);if (clarification) return clarification;- const normalized = text.toLowerCase();- if (this._isProgressContinuationText(normalized)) continue;- if (this._isProgressAckText(normalized)) continue;+ if (this._continuationTurn(message)) continue;return { index: i, taskIndex: i, clarificationIndex: -1, text, requestText: text, answers: [], pinnedIndices: [i] };}const index = this._findOriginalTaskIndex(messages);@@ -31405,10 +31404,32 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dreturn String(text || '').replace(/\s+/g, ' ').trim();}- // Bare acknowledgments carry no task identity; the anchor walk must not- // treat "ok" between steps as a task switch.- _isProgressAckText(text) {- return /^(?:ok(?:ay)?|yes|yep|yeah|sure|thanks|thank\s+you|great|good|nice|cool|perfect|got\s+it|sounds\s+good|alright|fine)[\s\d.,!?;:~*+-]*$/i.test(text);+ // What a short user turn does while an earlier task exists: continue it,+ // only acknowledge it, or ask for something. A model reads it in any+ // language, once, when the turn arrives; the answer is stored on the turn so+ // the task anchor, ledger scope and approved plan read it without words.+ // The Continue command is a continuation by construction. Ask turns, long+ // turns, source-bound shortcuts, scheduled resumes, first turns and turns+ // the model cannot read with confidence are requests.+ async _markUserTurnKind(tabId, messages, turn, text, mode, runOptions = {}, { sourceBound = false } = {}) {+ this._applyUserTurnKind(turn, await this._userTurnKind(tabId, messages, text, mode, runOptions, sourceBound));+ }++ _applyUserTurnKind(turn, kind) {+ if (turn && typeof turn === 'object' && (kind === 'continue' || kind === 'acknowledge')) turn.webbrainTurnKind = kind;+ }++ async _userTurnKind(tabId, messages, text, mode, runOptions = {}, sourceBound = false) {+ if (runOptions?.trustedContinuation === true) return 'continue';+ const value = typeof text === 'string' ? text.trim() : '';+ if (sourceBound || !this._isActionMode(mode) || !value || value.length > 160+ || this._isScheduledResumeTurn(value) || this._activeTaskBinding(messages || []).index < 0) return 'request';+ const verdict = await this._semanticDecision(tabId, 'user_turn_kind', { request: value });+ return verdict.choice === 'continue' || verdict.choice === 'acknowledge' ? verdict.choice : 'request';+ }++ _continuationTurn(message) {+ return message?.webbrainTurnKind === 'continue' || message?.webbrainTurnKind === 'acknowledge';}// Latest user task message that is NOT a continuation phrase ("continue",@@ -31518,7 +31539,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (!sessionText) return true;// Degenerate stored text (session persisted during a continuation turn)// carries no task identity to compare against; keep the old behavior.- if (this._isProgressContinuationText(sessionText.toLowerCase())) return true;+ if (this._isContinuationTurnText(tabId, sessionText)) return true;const anchor = this._progressTaskTextKey(this._progressTaskAnchorText(tabId) || this._originalTaskText(tabId));if (!anchor) return true;return sessionText === anchor;@@ -32407,17 +32428,21 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}_latestTaskText(tabId) {+ const message = this._latestTaskMessage(tabId);+ return message ? this._plannerUserAuthoredText(message) : '';+ }++ _latestTaskMessage(tabId) {const messages = this.conversations.get(tabId) || [];for (let i = messages.length - 1; i >= 1; i--) {const m = messages[i];if (m.role !== 'user') continue;if (this._isScheduledResumeTurn(m)) continue;if (this._isAgentInjectedUserMessage(m)) continue;- const text = this._plannerUserAuthoredText(m);- if (!text) continue;- return text;+ if (!this._plannerUserAuthoredText(m)) continue;+ return m;}- return '';+ return null;}_progressIntentClassifierMessages(taskText, siteContext = {}) {@@ -32947,20 +32972,16 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}_currentTaskIsProgressContinuation(tabId) {- return this._isProgressContinuationText(this._latestTaskText(tabId).toLowerCase());+ return this._latestTaskMessage(tabId)?.webbrainTurnKind === 'continue';}- _isProgressContinuationText(text) {- if (!text) return false;- // continueProcessing uses this exact command for the existing task.- if (text === 'please continue from where you left off.') return true;- if (/^(?:please\s+)?(?:continue|keep\s+going|go\s+on|proceed|resume|carry\s+on|next|do\s+the\s+rest|finish\s+(?:the\s+)?(?:rest|remaining)|keep\s+working)(?:\s+(?:please|with\s+(?:it|this|that|them|those|the\s+(?:task|list|queue|rest|remaining))))?[.!?]*$/.test(text)) {- return true;- }- if (/^(?:please\s+)?(?:continue|go\s+on|proceed|resume|carry\s+on|keep\s+(?:going|working))\s+(?:with\s+)?(?:the\s+)?(?:(?:existing|current|active|open|pending|progress)\s+)?(?:ledger|progress\s+ledger|task|work|list|queue|rows?|items?)[.!?]*$/.test(text)) {- return true;- }- return /^(?:please\s+)?(?:continue|go\s+on|proceed|resume|carry\s+on|keep\s+(?:going|working))\s+(?:with\s+)?(?:(?:the\s+)?(?:rest|remaining)\s+)?(?:following|unfollowing|starring|unstarring|watching|unwatching|connecting|subscribing|unsubscribing|saving|unsaving|liking|unliking|blocking|unblocking|reporting|sending|submitting|adding|removing|processing|collecting|scraping|visiting|opening)\b[\s\S]{0,120}\b(?:remaining|rest|rows|items|profiles|users|people|members|followers|following|stargazers|results|links|pages|contacts|accounts|repos|repositories|entries|records|comments|messages|emails|names|handles)\b[.!?]*$/.test(text);+ // Whether this text is a user turn of this conversation that only continued+ // or acknowledged the earlier task.+ _isContinuationTurnText(tabId, text) {+ const key = this._progressTaskTextKey(text);+ if (!key) return false;+ return (this.conversations.get(tabId) || []).some(message => message?.role === 'user'+ && this._continuationTurn(message) && this._progressTaskTextKey(this._plannerUserAuthoredText(message)) === key);}_currentTaskHasProgressIntent(tabId) {@@ -38445,8 +38466,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dreturn { success: false, dispatched: false, noDispatch: true, adapterFailure: true, error: 'carousel_navigate is unavailable: the current page is not a supported Instagram /p/<id>/ permalink.' };}const taskKey = this._progressTaskTextKey(this._latestTaskText(tabId));- const reverseRequested = /\b(?:reverse|backwards?|descending|last\s+to\s+first|right\s+to\s+left)\b|\b(?:tersten|geriye\s+doğru|sondan\s+başa)\b/i.test(this._latestTaskText(tabId));- const traversalDirection = reverseRequested ? 'reverse' : 'forward';+ // The order comes from the user's request, read by a model in any+ // language (never from the model driving the scan, which could+ // otherwise flip direction to revisit slides); no sure answer is the+ // usual order.+ const order = await this._semanticDecision(tabId, 'carousel_order', { request: this._latestTaskText(tabId) });+ const traversalDirection = order.choice === 'reverse' ? 'reverse' : 'forward';const storedState = this.carouselTraversalStates.get(tabId);const previousState = storedState?.canonicalPostUrl === target.canonicalPostUrl&& storedState.taskKey === taskKey@@ -39941,8 +39966,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dscreenshotCaptured: !!imageDataUrl,});if (completionDecision) verification.decision = { outcome: completionDecision.outcome, engine: completionDecision.engine, modality: completionDecision.modality, model: completionDecision.model };- if (!args.data_ref && completionDecision?.outcome === 'succeeded' && /upvotes|won.t get deleted|won.t be deleted|will not be removed/i.test(this._progressTaskAnchorText(tabId) || this._latestTaskText(tabId) || '')) args.summary += '\n\nPublication was verified. Future upvotes and moderation outcomes remain unverified.';-// If completionWarning fires, DO NOT terminate. Return a regular// failed tool result so the agent loop continues and the model// must actually submit (and verify) before it can call done again.@@ -39964,6 +39987,18 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}// After 2 blocks, let done through with a loud note in verification.}+ // A request that also expects votes or moderation to go a certain way+ // asks for something no run can verify. Whoever verified the completion+ // reads that from the request in any language: the active model's+ // verdict says so itself, and after a decision-model verdict the+ // decision model is asked; nothing else is called. Only a clear answer+ // adds the caveat.+ if (!args.data_ref && completionDecision?.outcome === 'succeeded' && completionDecision.engine !== 'calculation') {+ const later = completionDecision.engine === 'llm' ? completionDecision.laterOutcome+ : (await this._semanticDecision(tabId, 'future_outcome',+ { request: this._progressTaskAnchorText(tabId) || this._latestTaskText(tabId) || '' }, { mainModel: false })).choice;+ if (later === 'asked') args.summary += '\n\nPublication was verified. Future upvotes and moderation outcomes remain unverified.';+ }const runId = this.currentRunId.get(tabId);if (imageDataUrl && runId) {await trace.recordScreenshot(runId, null, imageDataUrl, 'done verification');@@ -46861,9 +46896,14 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d? this._selectionGroundingPriorMessageSet(tabId, messages): null;+ // What a short turn does is read while the page context is gathered.+ const userTurnKind = this._userTurnKind(tabId, messages, userMessage, mode, runOptions,+ selectionOnly || standaloneChatRun);+ userTurnKind.catch(() => {});const enriched = await this._enrichUserMessageWithCurrentPage(tabId, selectionOnly ? [] : messages, userMessage, costState, runOptions, onUpdate,);+ this._applyUserTurnKind(enriched, await userTurnKind);let standaloneWikipediaReferences = [];const localWikipediaRag = await this._applyStandaloneWikipediaRag(enriched, userMessage, runOptions, {tabId,@@ -48447,9 +48487,14 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d? this._selectionGroundingPriorMessageSet(tabId, messages): null;+ // What a short turn does is read while the page context is gathered.+ const userTurnKind = this._userTurnKind(tabId, messages, userMessage, mode, runOptions,+ selectionOnly || standaloneChatRun);+ userTurnKind.catch(() => {});const enriched = await this._enrichUserMessageWithCurrentPage(tabId, selectionOnly ? [] : messages, userMessage, costState, runOptions, onUpdate,);+ this._applyUserTurnKind(enriched, await userTurnKind);let standaloneWikipediaReferences = [];const localWikipediaRag = await this._applyStandaloneWikipediaRag(enriched, userMessage, runOptions, {tabId,diff --git a/src/chrome/src/agent/completion-runtime.js b/src/chrome/src/agent/completion-runtime.jsindex 3bf09a06f..0760d0d3f 100644--- a/src/chrome/src/agent/completion-runtime.js+++ b/src/chrome/src/agent/completion-runtime.js@@ -2,7 +2,7 @@ import { semanticCommitDocumentMatches } from './semantic-commit-navigation.js';import { DECISION_SETTINGS_KEYS, resolveDecisionConfig } from './decision-config.js';import { createSystemOneJudge } from './systemone-judge.js';import { redactSystemOneText, wrapSystemOneData, boundedSystemOneText as boundedText } from './systemone-evidence.js';-import { COMPLETION_INSTRUCTIONS, completionQuestions, decisionCompletionVerdict, llmCompletionVerdict, verifyCompletion, withCompletionTimeout, completionStopError } from './completion-verifier.js';+import { COMPLETION_INSTRUCTIONS, LATER_OUTCOME_FIELD, completionQuestions, decisionCompletionVerdict, llmCompletionVerdict, verifyCompletion, withCompletionTimeout, completionStopError } from './completion-verifier.js';import { calculationResultInText } from './calculator.js';import { isPageIndependentCalculationCompletion, literalCalculationSummaryFormatMatches } from './page-feedback-policy.js';@@ -328,7 +328,7 @@ async function evaluateBrowserCompletion(agent, tabId, options = {}) {// Leave bounded room for it and the verdict without overriding the// provider's reasoning configuration or adding another model request.const result = await withCompletionTimeout(requestSignal => agent._chatWithCostAllowance(provider, [- { role: 'system', content: COMPLETION_INSTRUCTIONS + ' Return only JSON {"outcome":"succeeded|pending|failed|uncertain","reason":"brief evidence-based reason"}. Do not call tools or perform actions.' },+ { role: 'system', content: `${COMPLETION_INSTRUCTIONS} Return only JSON {"outcome":"succeeded|pending|failed|uncertain","reason":"brief evidence-based reason","later":"asked|not_asked"}. ${LATER_OUTCOME_FIELD} Do not call tools or perform actions.` },{ role: 'user', content: modality === 'vision' ? [{ type: 'text', text: JSON.stringify(info) }, observation] : JSON.stringify(evidence.state) },], { temperature: 0, maxTokens: 4096, signal: requestSignal }, context.costState || agent._newCostRunState(), { tabId, generationName: 'completion_verification' }), signal, 10000);if (result.costAllowanceMessage) throw agent._costAllowanceError(result.costAllowanceMessage);diff --git a/src/chrome/src/agent/completion-verifier.js b/src/chrome/src/agent/completion-verifier.jsindex 0b3c09610..4d250e973 100644--- a/src/chrome/src/agent/completion-verifier.js+++ b/src/chrome/src/agent/completion-verifier.js@@ -30,10 +30,16 @@ export function decisionCompletionVerdict(result, threshold = .9) {confidence: answer.confidence, model: result.model, provider: result.provider, usage: result.usage };}+// The active model's judge also says whether the task expects an outcome+// that only happens after it ends (votes, reactions, moderation). Only an+// exact "asked" counts; a missing or other value is no answer and never+// invalidates the verdict itself.+export const LATER_OUTCOME_FIELD = 'Set "later" to "asked" when the task also asks for or expects an outcome that can only happen after it ends, such as votes or reactions from other people, or moderators not removing what was posted; otherwise set it to "not_asked". Judge the meaning in any language.';+export function llmCompletionVerdict(content) {const parsed = JSON.parse(String(content || '').trim().replace(/^```(?:json)?\s*|\s*```$/g, ''));if (!parsed || !COMPLETION_OUTCOMES.includes(parsed.outcome) || typeof parsed.reason !== 'string' || parsed.reason.length > 1500) throw new Error('Invalid LLM completion verdict.');- return { outcome: parsed.outcome, reason: parsed.reason };+ return { outcome: parsed.outcome, reason: parsed.reason, ...(parsed.later === 'asked' ? { laterOutcome: 'asked' } : {}) };}export function completionStopError(error, signal) {diff --git a/src/chrome/src/agent/semantic-decisions.js b/src/chrome/src/agent/semantic-decisions.jsindex 516da2e35..e8badc6ee 100644--- a/src/chrome/src/agent/semantic-decisions.js+++ b/src/chrome/src/agent/semantic-decisions.js@@ -45,6 +45,37 @@ export const SEMANTIC_QUESTIONS = Object.freeze({}),authorizing: Object.freeze([]),}),+ user_turn_kind: Object.freeze({+ instructions: 'A user sent the short message in `request` to a browser agent while an earlier task was in progress '+ + 'or had just finished. Decide what the message does. Judge the meaning in any language.',+ choices: Object.freeze({+ continue: 'It only asks to continue, resume or keep going with the earlier task, or to do the rest of it, without adding, removing or changing anything.',+ acknowledge: 'It only acknowledges, thanks or agrees, and asks for nothing.',+ request: 'It asks for something: a new task, a question, or a change, correction, addition or narrowing of the earlier task.',+ }),+ // Keeping the earlier task in force needs a sure answer.+ authorizing: Object.freeze(['continue', 'acknowledge']),+ }),+ carousel_order: Object.freeze({+ instructions: 'A browser agent is going through the slides of one carousel (an image or post gallery), one slide at a '+ + 'time. Decide whether the user\'s request in `request` asks to go through the slides in reverse order, from the '+ + 'last slide to the first. Judge the meaning in any language.',+ choices: Object.freeze({+ reverse: 'The request asks to go through the slides in reverse order, from the last to the first.',+ forward: 'The request asks for the usual order, or does not say.',+ }),+ authorizing: Object.freeze([]),+ }),+ future_outcome: Object.freeze({+ instructions: 'A browser agent finished a task and verified what it did. Decide whether the user\'s request in '+ + '`request` also asks for, or expects, an outcome that can only happen after the task ends, such as votes or '+ + 'reactions from other people, or moderators not removing what was posted. Judge the meaning in any language.',+ choices: Object.freeze({+ asked: 'The request asks for or expects such a later outcome.',+ not_asked: 'The request asks for nothing that only happens later.',+ }),+ authorizing: Object.freeze([]),+ }),sending_forbidden: Object.freeze({instructions: 'A browser agent is about to send the message in `page.message` to `page.recipients` on `page.site`, '+ 'although the task did not clearly ask for this send. Decide whether the user\'s latest request in `request` 'diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex 85d7c9102..ece0a10e4 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -6948,9 +6948,10 @@ export class Agent extends LoopDetector {* and sure; otherwise the active model answers with a quoted reason. Returns* { choice, evidence, source } where choice is null when no sure answer was* available; callers then ask the user or do not proceed. Identical- * questions are answered once.+ * questions are answered once. `mainModel: false` asks the decision model+ * only, for a note that is not worth a call to the active model.*/- async _semanticDecision(tabId, kind, { request = '', page = {} } = {}, { provider = this._activeProvider(tabId), signal = null } = {}) {+ async _semanticDecision(tabId, kind, { request = '', page = {} } = {}, { provider = this._activeProvider(tabId), signal = null, mainModel = true } = {}) {const spec = semanticQuestion(kind);const trusted = String(request ?? '').slice(0, 6000);const data = boundedSemanticData(page);@@ -6983,7 +6984,7 @@ export class Agent extends LoopDetector {if (this._isCostAllowanceError(error) || this._checkAbort(tabId)) throw error;this.recordSystemOneVerdict(tabId, { decision: 'fallback', reason: `${kind}_${systemOneFailureReason(error)}` }, context);}- if (!provider?.chat || this._checkAbort(tabId)) return { choice: null, evidence: '', source: 'unavailable' };+ if (!mainModel || !provider?.chat || this._checkAbort(tabId)) return { choice: null, evidence: '', source: 'unavailable' };try {const messages = semanticDecisionMessages(kind, trusted, data, text => this._wrapUntrusted('read_page', text));const response = await withCompletionTimeout(async completionSignal => {@@ -19035,9 +19036,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (steered) return steered;const clarification = this._plannerClarificationTaskBinding(messages, i);if (clarification) return clarification;- const normalized = text.toLowerCase();- if (this._isProgressContinuationText(normalized)) continue;- if (this._isProgressAckText(normalized)) continue;+ if (this._continuationTurn(message)) continue;return { index: i, taskIndex: i, clarificationIndex: -1, text, requestText: text, answers: [], pinnedIndices: [i] };}const index = this._findOriginalTaskIndex(messages);@@ -28698,10 +28697,32 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dreturn String(text || '').replace(/\s+/g, ' ').trim();}- // Bare acknowledgments carry no task identity; the anchor walk must not- // treat "ok" between steps as a task switch.- _isProgressAckText(text) {- return /^(?:ok(?:ay)?|yes|yep|yeah|sure|thanks|thank\s+you|great|good|nice|cool|perfect|got\s+it|sounds\s+good|alright|fine)[\s\d.,!?;:~*+-]*$/i.test(text);+ // What a short user turn does while an earlier task exists: continue it,+ // only acknowledge it, or ask for something. A model reads it in any+ // language, once, when the turn arrives; the answer is stored on the turn so+ // the task anchor, ledger scope and approved plan read it without words.+ // The Continue command is a continuation by construction. Ask turns, long+ // turns, source-bound shortcuts, scheduled resumes, first turns and turns+ // the model cannot read with confidence are requests.+ async _markUserTurnKind(tabId, messages, turn, text, mode, runOptions = {}, { sourceBound = false } = {}) {+ this._applyUserTurnKind(turn, await this._userTurnKind(tabId, messages, text, mode, runOptions, sourceBound));+ }++ _applyUserTurnKind(turn, kind) {+ if (turn && typeof turn === 'object' && (kind === 'continue' || kind === 'acknowledge')) turn.webbrainTurnKind = kind;+ }++ async _userTurnKind(tabId, messages, text, mode, runOptions = {}, sourceBound = false) {+ if (runOptions?.trustedContinuation === true) return 'continue';+ const value = typeof text === 'string' ? text.trim() : '';+ if (sourceBound || !this._isActionMode(mode) || !value || value.length > 160+ || this._isScheduledResumeTurn(value) || this._activeTaskBinding(messages || []).index < 0) return 'request';+ const verdict = await this._semanticDecision(tabId, 'user_turn_kind', { request: value });+ return verdict.choice === 'continue' || verdict.choice === 'acknowledge' ? verdict.choice : 'request';+ }++ _continuationTurn(message) {+ return message?.webbrainTurnKind === 'continue' || message?.webbrainTurnKind === 'acknowledge';}// Latest user task message that is NOT a continuation phrase ("continue",@@ -28811,7 +28832,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (!sessionText) return true;// Degenerate stored text (session persisted during a continuation turn)// carries no task identity to compare against; keep the old behavior.- if (this._isProgressContinuationText(sessionText.toLowerCase())) return true;+ if (this._isContinuationTurnText(tabId, sessionText)) return true;const anchor = this._progressTaskTextKey(this._progressTaskAnchorText(tabId) || this._originalTaskText(tabId));if (!anchor) return true;return sessionText === anchor;@@ -29700,17 +29721,21 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}_latestTaskText(tabId) {+ const message = this._latestTaskMessage(tabId);+ return message ? this._plannerUserAuthoredText(message) : '';+ }++ _latestTaskMessage(tabId) {const messages = this.conversations.get(tabId) || [];for (let i = messages.length - 1; i >= 1; i--) {const m = messages[i];if (m.role !== 'user') continue;if (this._isScheduledResumeTurn(m)) continue;if (this._isAgentInjectedUserMessage(m)) continue;- const text = this._plannerUserAuthoredText(m);- if (!text) continue;- return text;+ if (!this._plannerUserAuthoredText(m)) continue;+ return m;}- return '';+ return null;}_progressIntentClassifierMessages(taskText, siteContext = {}) {@@ -30240,20 +30265,16 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}_currentTaskIsProgressContinuation(tabId) {- return this._isProgressContinuationText(this._latestTaskText(tabId).toLowerCase());+ return this._latestTaskMessage(tabId)?.webbrainTurnKind === 'continue';}- _isProgressContinuationText(text) {- if (!text) return false;- // continueProcessing uses this exact command for the existing task.- if (text === 'please continue from where you left off.') return true;- if (/^(?:please\s+)?(?:continue|keep\s+going|go\s+on|proceed|resume|carry\s+on|next|do\s+the\s+rest|finish\s+(?:the\s+)?(?:rest|remaining)|keep\s+working)(?:\s+(?:please|with\s+(?:it|this|that|them|those|the\s+(?:task|list|queue|rest|remaining))))?[.!?]*$/.test(text)) {- return true;- }- if (/^(?:please\s+)?(?:continue|go\s+on|proceed|resume|carry\s+on|keep\s+(?:going|working))\s+(?:with\s+)?(?:the\s+)?(?:(?:existing|current|active|open|pending|progress)\s+)?(?:ledger|progress\s+ledger|task|work|list|queue|rows?|items?)[.!?]*$/.test(text)) {- return true;- }- return /^(?:please\s+)?(?:continue|go\s+on|proceed|resume|carry\s+on|keep\s+(?:going|working))\s+(?:with\s+)?(?:(?:the\s+)?(?:rest|remaining)\s+)?(?:following|unfollowing|starring|unstarring|watching|unwatching|connecting|subscribing|unsubscribing|saving|unsaving|liking|unliking|blocking|unblocking|reporting|sending|submitting|adding|removing|processing|collecting|scraping|visiting|opening)\b[\s\S]{0,120}\b(?:remaining|rest|rows|items|profiles|users|people|members|followers|following|stargazers|results|links|pages|contacts|accounts|repos|repositories|entries|records|comments|messages|emails|names|handles)\b[.!?]*$/.test(text);+ // Whether this text is a user turn of this conversation that only continued+ // or acknowledged the earlier task.+ _isContinuationTurnText(tabId, text) {+ const key = this._progressTaskTextKey(text);+ if (!key) return false;+ return (this.conversations.get(tabId) || []).some(message => message?.role === 'user'+ && this._continuationTurn(message) && this._progressTaskTextKey(this._plannerUserAuthoredText(message)) === key);}_currentTaskHasProgressIntent(tabId) {@@ -34820,8 +34841,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dreturn { success: false, dispatched: false, noDispatch: true, adapterFailure: true, error: 'carousel_navigate is unavailable: the current page is not a supported Instagram /p/<id>/ permalink.' };}const taskKey = this._progressTaskTextKey(this._latestTaskText(tabId));- const reverseRequested = /\b(?:reverse|backwards?|descending|last\s+to\s+first|right\s+to\s+left)\b|\b(?:tersten|geriye\s+doğru|sondan\s+başa)\b/i.test(this._latestTaskText(tabId));- const traversalDirection = reverseRequested ? 'reverse' : 'forward';+ // The order comes from the user's request, read by a model in any+ // language (never from the model driving the scan, which could+ // otherwise flip direction to revisit slides); no sure answer is the+ // usual order.+ const order = await this._semanticDecision(tabId, 'carousel_order', { request: this._latestTaskText(tabId) });+ const traversalDirection = order.choice === 'reverse' ? 'reverse' : 'forward';const storedState = this.carouselTraversalStates.get(tabId);const previousState = storedState?.canonicalPostUrl === target.canonicalPostUrl&& storedState.taskKey === taskKey@@ -36032,8 +36057,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dscreenshotCaptured: !!dataUrl,});if (completionDecision) verification.decision = { outcome: completionDecision.outcome, engine: completionDecision.engine, modality: completionDecision.modality, model: completionDecision.model };- if (!args.data_ref && completionDecision?.outcome === 'succeeded' && /upvotes|won.t get deleted|won.t be deleted|will not be removed/i.test(this._progressTaskAnchorText(tabId) || this._latestTaskText(tabId) || '')) args.summary += '\n\nPublication was verified. Future upvotes and moderation outcomes remain unverified.';-// If completionWarning fires, DO NOT terminate. Return a failed// tool result so the agent loop continues and the model must// actually submit (and verify) before it can call done again.@@ -36055,6 +36078,18 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}// After 2 blocks, let done through with a loud note in verification.}+ // A request that also expects votes or moderation to go a certain way+ // asks for something no run can verify. Whoever verified the completion+ // reads that from the request in any language: the active model's+ // verdict says so itself, and after a decision-model verdict the+ // decision model is asked; nothing else is called. Only a clear answer+ // adds the caveat.+ if (!args.data_ref && completionDecision?.outcome === 'succeeded' && completionDecision.engine !== 'calculation') {+ const later = completionDecision.engine === 'llm' ? completionDecision.laterOutcome+ : (await this._semanticDecision(tabId, 'future_outcome',+ { request: this._progressTaskAnchorText(tabId) || this._latestTaskText(tabId) || '' }, { mainModel: false })).choice;+ if (later === 'asked') args.summary += '\n\nPublication was verified. Future upvotes and moderation outcomes remain unverified.';+ }const runId = this.currentRunId.get(tabId);if (dataUrl && runId) {await trace.recordScreenshot(runId, null, dataUrl, 'done verification');@@ -39238,9 +39273,14 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d? this._selectionGroundingPriorMessageSet(tabId, messages): null;+ // What a short turn does is read while the page context is gathered.+ const userTurnKind = this._userTurnKind(tabId, messages, userMessage, mode, runOptions,+ selectionOnly || standaloneChatRun);+ userTurnKind.catch(() => {});const enriched = await this._enrichUserMessageWithCurrentPage(tabId, selectionOnly ? [] : messages, userMessage, costState, runOptions,);+ this._applyUserTurnKind(enriched, await userTurnKind);let sourceBoundTrimmedMessages = null;let sourceBoundMessagesAtTrim = null;const rawModelMessagesForRun = () => {@@ -40654,9 +40694,14 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d? this._selectionGroundingPriorMessageSet(tabId, messages): null;+ // What a short turn does is read while the page context is gathered.+ const userTurnKind = this._userTurnKind(tabId, messages, userMessage, mode, runOptions,+ selectionOnly || standaloneChatRun);+ userTurnKind.catch(() => {});const enriched = await this._enrichUserMessageWithCurrentPage(tabId, selectionOnly ? [] : messages, userMessage, costState, runOptions,);+ this._applyUserTurnKind(enriched, await userTurnKind);let sourceBoundTrimmedMessages = null;let sourceBoundMessagesAtTrim = null;const rawModelMessagesForRun = () => {diff --git a/src/firefox/src/agent/completion-runtime.js b/src/firefox/src/agent/completion-runtime.jsindex 3bf09a06f..0760d0d3f 100644--- a/src/firefox/src/agent/completion-runtime.js+++ b/src/firefox/src/agent/completion-runtime.js@@ -2,7 +2,7 @@ import { semanticCommitDocumentMatches } from './semantic-commit-navigation.js';import { DECISION_SETTINGS_KEYS, resolveDecisionConfig } from './decision-config.js';import { createSystemOneJudge } from './systemone-judge.js';import { redactSystemOneText, wrapSystemOneData, boundedSystemOneText as boundedText } from './systemone-evidence.js';-import { COMPLETION_INSTRUCTIONS, completionQuestions, decisionCompletionVerdict, llmCompletionVerdict, verifyCompletion, withCompletionTimeout, completionStopError } from './completion-verifier.js';+import { COMPLETION_INSTRUCTIONS, LATER_OUTCOME_FIELD, completionQuestions, decisionCompletionVerdict, llmCompletionVerdict, verifyCompletion, withCompletionTimeout, completionStopError } from './completion-verifier.js';import { calculationResultInText } from './calculator.js';import { isPageIndependentCalculationCompletion, literalCalculationSummaryFormatMatches } from './page-feedback-policy.js';@@ -328,7 +328,7 @@ async function evaluateBrowserCompletion(agent, tabId, options = {}) {// Leave bounded room for it and the verdict without overriding the// provider's reasoning configuration or adding another model request.const result = await withCompletionTimeout(requestSignal => agent._chatWithCostAllowance(provider, [- { role: 'system', content: COMPLETION_INSTRUCTIONS + ' Return only JSON {"outcome":"succeeded|pending|failed|uncertain","reason":"brief evidence-based reason"}. Do not call tools or perform actions.' },+ { role: 'system', content: `${COMPLETION_INSTRUCTIONS} Return only JSON {"outcome":"succeeded|pending|failed|uncertain","reason":"brief evidence-based reason","later":"asked|not_asked"}. ${LATER_OUTCOME_FIELD} Do not call tools or perform actions.` },{ role: 'user', content: modality === 'vision' ? [{ type: 'text', text: JSON.stringify(info) }, observation] : JSON.stringify(evidence.state) },], { temperature: 0, maxTokens: 4096, signal: requestSignal }, context.costState || agent._newCostRunState(), { tabId, generationName: 'completion_verification' }), signal, 10000);if (result.costAllowanceMessage) throw agent._costAllowanceError(result.costAllowanceMessage);diff --git a/src/firefox/src/agent/completion-verifier.js b/src/firefox/src/agent/completion-verifier.jsindex 0b3c09610..4d250e973 100644--- a/src/firefox/src/agent/completion-verifier.js+++ b/src/firefox/src/agent/completion-verifier.js@@ -30,10 +30,16 @@ export function decisionCompletionVerdict(result, threshold = .9) {confidence: answer.confidence, model: result.model, provider: result.provider, usage: result.usage };}+// The active model's judge also says whether the task expects an outcome+// that only happens after it ends (votes, reactions, moderation). Only an+// exact "asked" counts; a missing or other value is no answer and never+// invalidates the verdict itself.+export const LATER_OUTCOME_FIELD = 'Set "later" to "asked" when the task also asks for or expects an outcome that can only happen after it ends, such as votes or reactions from other people, or moderators not removing what was posted; otherwise set it to "not_asked". Judge the meaning in any language.';+export function llmCompletionVerdict(content) {const parsed = JSON.parse(String(content || '').trim().replace(/^```(?:json)?\s*|\s*```$/g, ''));if (!parsed || !COMPLETION_OUTCOMES.includes(parsed.outcome) || typeof parsed.reason !== 'string' || parsed.reason.length > 1500) throw new Error('Invalid LLM completion verdict.');- return { outcome: parsed.outcome, reason: parsed.reason };+ return { outcome: parsed.outcome, reason: parsed.reason, ...(parsed.later === 'asked' ? { laterOutcome: 'asked' } : {}) };}export function completionStopError(error, signal) {diff --git a/src/firefox/src/agent/semantic-decisions.js b/src/firefox/src/agent/semantic-decisions.jsindex 516da2e35..e8badc6ee 100644--- a/src/firefox/src/agent/semantic-decisions.js+++ b/src/firefox/src/agent/semantic-decisions.js@@ -45,6 +45,37 @@ export const SEMANTIC_QUESTIONS = Object.freeze({}),authorizing: Object.freeze([]),}),+ user_turn_kind: Object.freeze({+ instructions: 'A user sent the short message in `request` to a browser agent while an earlier task was in progress '+ + 'or had just finished. Decide what the message does. Judge the meaning in any language.',+ choices: Object.freeze({+ continue: 'It only asks to continue, resume or keep going with the earlier task, or to do the rest of it, without adding, removing or changing anything.',+ acknowledge: 'It only acknowledges, thanks or agrees, and asks for nothing.',+ request: 'It asks for something: a new task, a question, or a change, correction, addition or narrowing of the earlier task.',+ }),+ // Keeping the earlier task in force needs a sure answer.+ authorizing: Object.freeze(['continue', 'acknowledge']),+ }),+ carousel_order: Object.freeze({+ instructions: 'A browser agent is going through the slides of one carousel (an image or post gallery), one slide at a '+ + 'time. Decide whether the user\'s request in `request` asks to go through the slides in reverse order, from the '+ + 'last slide to the first. Judge the meaning in any language.',+ choices: Object.freeze({+ reverse: 'The request asks to go through the slides in reverse order, from the last to the first.',+ forward: 'The request asks for the usual order, or does not say.',+ }),+ authorizing: Object.freeze([]),+ }),+ future_outcome: Object.freeze({+ instructions: 'A browser agent finished a task and verified what it did. Decide whether the user\'s request in '+ + '`request` also asks for, or expects, an outcome that can only happen after the task ends, such as votes or '+ + 'reactions from other people, or moderators not removing what was posted. Judge the meaning in any language.',+ choices: Object.freeze({+ asked: 'The request asks for or expects such a later outcome.',+ not_asked: 'The request asks for nothing that only happens later.',+ }),+ authorizing: Object.freeze([]),+ }),sending_forbidden: Object.freeze({instructions: 'A browser agent is about to send the message in `page.message` to `page.recipients` on `page.site`, '+ 'although the task did not clearly ask for this send. Decide whether the user\'s latest request in `request` 'diff --git a/test/completion-verifier.mjs b/test/completion-verifier.mjsindex e72acc87b..5ac65e1b4 100644--- a/test/completion-verifier.mjs+++ b/test/completion-verifier.mjs@@ -110,6 +110,14 @@ for (const build of ['chrome', 'firefox']) {assert.throws(() => verifier.llmCompletionVerdict('{"outcome":"succeeded"}'));assert.equal(verifier.llmCompletionVerdict('{"outcome":"uncertain","reason":"rules were not observed"}').outcome, 'uncertain');assert.match(verifier.COMPLETION_INSTRUCTIONS, /unrelated comment/); assert.match(verifier.COMPLETION_INSTRUCTIONS, /Future popularity/);+ // The judge also says whether the task expects a later outcome; only an+ // exact "asked" counts, and no other value invalidates the verdict.+ assert.equal(verifier.llmCompletionVerdict('{"outcome":"succeeded","reason":"posted","later":"asked"}').laterOutcome, 'asked');+ for (const later of ['not_asked', 'ASKED', 'yes', '', null, true]) {+ const verdict = verifier.llmCompletionVerdict(JSON.stringify({ outcome: 'succeeded', reason: 'posted', later }));+ assert.equal(verdict.outcome, 'succeeded'); assert.equal(verdict.laterOutcome, undefined, JSON.stringify(later));+ }+ assert.match(verifier.LATER_OUTCOME_FIELD, /any language/);});test(`${build}: discovery includes every decision publisher and per-model vision/rates`, async () => {const data = [ { id: 'other/decision', architecture: { output_modalities: ['decisions'], input_modalities: ['text', 'image'] }, pricing: { prompt: '.0000002' } }, { id: 'chat-only', architecture: { output_modalities: ['text'] } } ];@@ -186,10 +194,12 @@ for (const build of ['chrome', 'firefox']) {llmCalls++;assert.equal(options.tools, undefined); assert.equal(options.maxTokens, 4096);assert.match(messages[0].content, /Do not call tools/);- return { content: JSON.stringify({ outcome: llmCalls === 1 ? 'uncertain' : 'succeeded', reason: 'Published resource is visible.' }) };+ assert.ok(messages[0].content.includes(verifier.LATER_OUTCOME_FIELD), 'the judge is asked about later outcomes in the same request');+ return { content: JSON.stringify({ outcome: llmCalls === 1 ? 'uncertain' : 'succeeded', reason: 'Published resource is visible.', later: 'asked' }) };};verdict = await runtime.verifyBrowserCompletion(agent, 1);assert.equal(verdict.engine, 'llm'); assert.equal(verdict.modality, 'ax'); assert.equal(llmCalls, 2, 'active LLM must use its own vision and AX tiers');+ assert.equal(verdict.laterOutcome, 'asked');stored.systemOneDoneEnabled = true;agent.evaluateSystemOne = async () => { stamp = 'changed-during-verification'; const result = response(); result.model = 'kev-latest'; return result; };verdict = await runtime.verifyBrowserCompletion(agent, 1);diff --git a/test/lifecycle-steering-restart.mjs b/test/lifecycle-steering-restart.mjsindex 25110296e..78a03e85d 100644--- a/test/lifecycle-steering-restart.mjs+++ b/test/lifecycle-steering-restart.mjs@@ -11,6 +11,7 @@ import assert from 'node:assert/strict';import fs from 'node:fs';import vm from 'node:vm';import { test } from 'node:test';+import { withoutFixedChoiceAnswers } from './semantic-decision-stub.mjs';const PAGE_URL = 'https://example.com/search';function persistentArea() {@@ -61,7 +62,7 @@ const journaled = tab => session.data.get(`agentSteer:${tab}`)?.entries || [];function makeAgent(Agent, next) {const provider = {name: 'steering restart test', model: 'test', promptTier: 'full', contextWindow: 128000,- supportsTools: true, supportsVision: false, chat: (messages, options) => next(messages, options),+ supportsTools: true, supportsVision: false, chat: withoutFixedChoiceAnswers((messages, options) => next(messages, options)),};const agent = new Agent({ getActive: () => provider, getProvider: () => provider, getVisionProvider: async () => null });// Conversation hydration and persistence stay real: they are what a restart keeps.diff --git a/test/planner-repair-authority.mjs b/test/planner-repair-authority.mjsindex 462c2ed52..6e136267b 100644--- a/test/planner-repair-authority.mjs+++ b/test/planner-repair-authority.mjs@@ -110,9 +110,11 @@ for (const browser of ['chrome', 'firefox']) {});test(`${browser}: explicit Continue and acknowledgment preserve the active approved plan`, async () => {- for (const text of ['continue', 'ok']) {+ // The runtime marks what a short turn does (a model reads it in any+ // language) before the planner gate sees it.+ for (const [text, kind] of [['continue', 'continue'], ['ok', 'acknowledge'], ['devam et', 'continue'], ['teşekkürler', 'acknowledge']]) {const agent = await planned();- const captured = await gate(agent, text);+ const captured = await gate(agent, text, '', {}, { webbrainTurnKind: kind });assert.ok(captured.followUp.scratchpadFacts.includes(oldPlan));assert.equal(agent._progressTaskAnchorText(tab), oldTask);assert.ok(scratch(agent).includes(notes));diff --git a/test/pure-calculation-tools.mjs b/test/pure-calculation-tools.mjsindex 043c595f4..6403c0ef2 100644--- a/test/pure-calculation-tools.mjs+++ b/test/pure-calculation-tools.mjs@@ -1,6 +1,7 @@import assert from 'node:assert/strict';import { test } from 'node:test';import { readFileSync } from 'node:fs';+import { withoutFixedChoiceAnswers } from './semantic-decision-stub.mjs';const ORIGINAL_CALC_CORRECTION = readFileSync(new URL('./fixtures/literal-calculation-correction.txt', import.meta.url), 'utf8').trim();@@ -21,7 +22,7 @@ let nextTab = 2600;function makeAgent(Agent, next) {const provider = {name: 'feedback progress test', model: 'test', promptTier: 'full', contextWindow: 128000,- supportsTools: true, supportsVision: false, chat: next,+ supportsTools: true, supportsVision: false, chat: withoutFixedChoiceAnswers(next),async *chatStream(messages, options) {const response = await next(messages, options);if (response.content) yield { type: 'text', content: response.content };diff --git a/test/run.js b/test/run.jsindex 4d9869f10..00295ee8e 100644--- a/test/run.js+++ b/test/run.js@@ -9359,7 +9359,14 @@ test('Instagram carousel navigation enumerates 16 slides monotonically and recorassert.equal(outOfRange.outOfRange, true);assert.equal(outOfRange.terminal, true);- agent._latestTaskText = () => 'Traverse this carousel in reverse order.';+ // A model reads the order from the request, in any language.+ const reverseRequest = 'Recorre este carrusel del último al primero.';+ const orders = [];+ agent._semanticDecision = async (_tab, kind, { request }) => {+ orders.push({ kind, request });+ return { choice: kind === 'carousel_order' && request === reverseRequest ? 'reverse' : 'forward', evidence: '', source: 'main_model' };+ };+ agent._latestTaskText = () => reverseRequest;const reverseStart = await AgentClass.prototype.executeTool.call(agent, tabId, 'carousel_navigate', { index: 16 });const reverseNext = await AgentClass.prototype.executeTool.call(agent, tabId, 'carousel_navigate', { index: 15 });assert.equal(reverseStart.success, true, `${label}: fresh explicit reverse traversal did not reset monotonic state`);@@ -9368,6 +9375,18 @@ test('Instagram carousel navigation enumerates 16 slides monotonically and recorconst reverseRevisit = await AgentClass.prototype.executeTool.call(agent, tabId, 'carousel_navigate', { index: 16 });assert.equal(reverseRevisit.success, false, `${label}: reverse traversal revisited a processed slide`);assert.equal(reverseRevisit.nonMonotonic, true);+ assert.deepEqual(orders.at(-1), { kind: 'carousel_order', request: reverseRequest },+ `${label}: the order was not read from the request as written`);+ // No sure answer keeps the usual order: the reverse scan cannot continue.+ agent._semanticDecision = async () => ({ choice: null, evidence: '', source: 'unavailable' });+ const unsure = await AgentClass.prototype.executeTool.call(agent, tabId, 'carousel_navigate', { index: 14 });+ assert.equal(unsure.traversalDirection === 'reverse', false, `${label}: an unread request reversed the scan`);+ // A request that only mentions the word is read as a whole: the usual order.+ agent._semanticDecision = async (_tab, kind) => ({ choice: kind === 'carousel_order' ? 'forward' : null, evidence: '', source: 'main_model' });+ agent._latestTaskText = () => 'Record the reverse-side caption of every slide.';+ const mention = await AgentClass.prototype.executeTool.call(agent, tabId, 'carousel_navigate', { index: 3 });+ assert.equal(mention.success, true);+ assert.equal(mention.traversalDirection, 'forward', `${label}: the word "reverse" reversed the scan`);}});@@ -55279,7 +55298,7 @@ test('resume task identities survive persistence and keep identical requests sepconst origin = h.jobs()[0].resumeTaskId;const saved = h.agent._conversationStorageEntry(77);h.agent.conversations.set(77, structuredClone(saved.messages));- h.agent.conversations.get(77).push({ role: 'user', content: 'continue' });+ h.agent.conversations.get(77).push({ role: 'user', content: 'continue', webbrainTurnKind: 'continue' });assert.equal(h.agent._resumeTaskId(77), origin, `${label}: saved task identity was lost on continuation`);h.agent.conversations.get(77).push({ role: 'user', content: saved.messages[1].content });assert.equal(h.agent._resumeTaskId(77), '', `${label}: an identical new request inherited the old task identity`);@@ -87611,7 +87630,7 @@ test('agent preserves active progress ledger for ongoing-action continuation wor{ role: 'system', content: 'sys' },{ role: 'user', content: 'Follow every stargazer on this page.' },{ role: 'assistant', content: 'Paused with one row unresolved.' },- { role: 'user', content: 'Continue following the remaining stargazers.' },+ { role: 'user', content: 'Continue following the remaining stargazers.', webbrainTurnKind: 'continue' },]);assert.equal(agent._hasProgressLedgerContext(tabId), true, `${AgentClass.name}: ongoing-action continuation did not keep ledger context`);@@ -87641,7 +87660,7 @@ test('agent preserves keyed rows for ledger continuation wording', () => {{ role: 'system', content: 'sys' },{ role: 'user', content: 'Follow every stargazer on this page.' },{ role: 'assistant', content: 'Paused with one row unresolved.' },- { role: 'user', content: 'Continue the existing ledger.' },+ { role: 'user', content: 'Continue the existing ledger.', webbrainTurnKind: 'continue' },]);assert.equal(agent._currentTaskHasProgressIntent(tabId), true, `${AgentClass.name}: ledger continuation lost progress intent`);@@ -90189,14 +90208,24 @@ test('decision completion recognizes published Reddit content while preserving vagent._completionDocumentStamp = async () => 'current-document';agent._captureViewportProbe = async () => page;let outcome = 'succeeded';- agent.evaluateSystemOne = async () => ({ model: 'kev-latest', answers: { task_outcome: {- type: 'choice', choice: outcome, confidence: .99,- probabilities: Object.fromEntries(['succeeded', 'pending', 'failed', 'uncertain'].map(key => [key, key === outcome ? .97 : .01])),- } } });+ // The decision model answers each question: the task outcome, and+ // whether the request expects a later outcome (votes, moderation).+ let later = 'asked';+ const laterQuestions = [];+ agent.evaluateSystemOne = async (_tab, _client, args) => (args?.questions?.future_outcome+ ? (laterQuestions.push(args.state), { model: 'kev-latest', answers: { future_outcome: { type: 'choice', choice: later,+ confidence: .95, probabilities: { asked: later === 'asked' ? .95 : .05, not_asked: later === 'asked' ? .05 : .95 } } } })+ : { model: 'kev-latest', answers: { task_outcome: {+ type: 'choice', choice: outcome, confidence: .99,+ probabilities: Object.fromEntries(['succeeded', 'pending', 'failed', 'uncertain'].map(key => [key, key === outcome ? .97 : .01])),+ } } });const execute = agent.executeTool.bind(agent);agent.executeTool = (tab, name, args) => name === 'get_accessibility_tree'? Promise.resolve({ success: true, pageContent: 'Published WebBrain post by expected author; unrelated comment form.' }): execute(tab, name, args);+ const semanticDecision = agent._semanticDecision.bind(agent);+ const asked = [];+ agent._semanticDecision = (tab, kind, ...rest) => { asked.push(kind); return semanticDecision(tab, kind, ...rest); };const guard = { enabled: true, requiresSubmission: true, requiresStateChange: true };const submit = { dispatched: true, observedAfterSubmit: true, currentUrl: url, documentChanged: true };agent._planExecutionGuards.set(tabId, guard);@@ -90206,10 +90235,14 @@ test('decision completion recognizes published Reddit content while preserving vassert.equal(result.verification.decision.outcome, 'succeeded');assert.equal(guard.semanticSubmissionVerified, true);assert.match(result.summary, /Future upvotes and moderation outcomes remain unverified/);+ assert.match(JSON.stringify(laterQuestions[0]), /will get upvotes/, `${AgentClass.name}: the request was not read as written`);+ assert.deepEqual(asked.filter(kind => kind === 'future_outcome'), ['future_outcome']);submit.formValidationFailed = true;+ asked.length = 0;const invalid = await agent.executeTool(tabId, 'done', { summary: 'Published.', outcome: 'success' });assert.equal(invalid.blockedDone, true, `${AgentClass.name}: semantic acceptance bypassed form validation`);+ assert.deepEqual(asked.filter(kind => kind === 'future_outcome'), [], `${AgentClass.name}: a rejected completion asked about later outcomes`);submit.formValidationFailed = false;guard.siteWorkflow = { job: { requiresSubmission: true, id: 'reddit.publish' } };guard.semanticSubmissionVerified = false; guard.verifiedSubmissionEvidence = false;@@ -90228,6 +90261,84 @@ test('decision completion recognizes published Reddit content while preserving vconst publishedJson = await agent.executeTool(tabId, 'done_json', { summary: 'Published.', result: 'post-id' });assert.equal(publishedJson.doneJson, true); assert.equal(publishedJson.cloudResult, 'post-id');assert.match(publishedJson.summary, /Future upvotes and moderation outcomes remain unverified/);+ // A request that expects nothing later gets no caveat.+ agent._latestTaskText = () => 'Read the rules and publish the WebBrain post.';+ later = 'not_asked'; agent._completionVerdicts.clear();+ const plain = await agent.executeTool(tabId, 'done_json', { summary: 'Published.', result: 'post-id' });+ assert.doesNotMatch(plain.summary, /Future upvotes/, `${AgentClass.name}: a caveat was added to a request that expects nothing later`);+ }+ } finally {+ globalThis.chrome = previousChrome; globalThis.browser = previousBrowser;+ cdpClientCh.evaluate = previousEvaluate;+ cdpClientCh.attach = previousAttach; cdpClientCh.sendCommand = previousCommand;+ }+});++test('the active-model completion judge itself says whether a request expects later votes or moderation', async () => {+ const previousChrome = globalThis.chrome, previousBrowser = globalThis.browser;+ const previousEvaluate = cdpClientCh.evaluate;+ const previousAttach = cdpClientCh.attach, previousCommand = cdpClientCh.sendCommand;+ try {+ cdpClientCh.attach = async () => {};+ cdpClientCh.sendCommand = async () => ({});+ for (const [index, AgentClass] of [AgentCh, AgentFx].entries()) {+ const tabId = 24960 + index;+ const url = 'https://old.reddit.com/r/opencodeCLI/comments/new/webbrain';+ const page = { url, title: 'Published WebBrain post', openDialogCount: 0, relevantFormCount: 1, visibleFormCount: 1, successMessages: [] };+ // The decision model is off, so the active model judges the completion.+ const storage = { get: async () => ({ systemOneEnabled: false }) };+ globalThis.chrome = { ...previousChrome, storage: { ...previousChrome?.storage, local: storage } };+ globalThis.browser = { ...previousBrowser, storage: { ...previousBrowser?.storage, local: storage }, tabs: { ...previousBrowser?.tabs, get: async () => ({ id: tabId, url }), executeScript: async () => [page] } };+ cdpClientCh.evaluate = async () => ({ result: { value: page } });+ const provider = { model: 'test-model', supportsVision: false, config: { category: 'local' }, chat() {} };+ const agent = new AgentClass({ getActive: () => provider, getVisionProvider: async () => null });+ agent.conversationModes.set(tabId, 'act');+ agent.autoScreenshot = 'off';+ agent._persist = () => {};+ agent.systemOneContext = () => ({ isCurrent: () => true });+ agent._completionDocumentStamp = async () => 'current-document';+ agent._captureViewportProbe = async () => page;+ agent.evaluateSystemOne = async () => { throw new Error('The decision model is off.'); };+ const execute = agent.executeTool.bind(agent);+ agent.executeTool = (tab, name, args) => name === 'get_accessibility_tree'+ ? Promise.resolve({ success: true, pageContent: 'Published WebBrain post by expected author; unrelated comment form.' })+ : execute(tab, name, args);+ let later = 'asked';+ const judged = [];+ agent._chatWithCostAllowance = async (_provider, messages) => {+ judged.push(messages);+ return { content: JSON.stringify({ outcome: 'succeeded', reason: 'The requested post is published.', ...(later === undefined ? {} : { later }) }) };+ };+ const guard = { enabled: true, requiresSubmission: true, requiresStateChange: true };+ agent._planExecutionGuards.set(tabId, guard);+ agent._completionSubmitStates.set(tabId, { dispatched: true, observedAfterSubmit: true, currentUrl: url, documentChanged: true });+ const done = async request => {+ agent._latestTaskText = () => request;+ agent._completionVerdicts?.clear(); judged.length = 0;+ return agent.executeTool(tabId, 'done', { summary: 'Published the WebBrain post.', outcome: 'success' });+ };++ // A request in any language that expects votes and no removal.+ const expecting = 'Kuralları oku ve beğeni toplayacak, moderatörlerin silmeyeceği bir WebBrain gönderisi paylaş.';+ const result = await done(expecting);+ assert.equal(result.done, true, `${AgentClass.name}: the published post was not accepted`);+ assert.equal(result.verification.decision.engine, 'llm');+ assert.match(result.summary, /Future upvotes and moderation outcomes remain unverified/, `${AgentClass.name}: the judge's answer was ignored`);+ assert.equal(judged.length, 1, `${AgentClass.name}: the caveat cost another model call`);+ assert.match(judged[0][0].content, /"later":"asked\|not_asked"/);+ assert.match(judged[0][0].content, /Judge the meaning in any language/);+ assert.match(judged[0][1].content, /beğeni toplayacak/, `${AgentClass.name}: the judge did not read the request as written`);++ // A request that only mentions the word, or an answer that is not a+ // clear "asked", adds nothing.+ for (const [request, answer] of [['Publish a WebBrain post titled "How upvotes work".', 'not_asked'],+ [expecting, undefined], [expecting, 'yes'], [expecting, 'ASKED']]) {+ later = answer;+ const plain = await done(request);+ assert.equal(plain.done, true);+ assert.doesNotMatch(plain.summary, /Future upvotes/, `${AgentClass.name}: ${JSON.stringify(answer)} added a caveat`);+ assert.equal(judged.length, 1);+ }}} finally {globalThis.chrome = previousChrome; globalThis.browser = previousBrowser;@@ -99111,7 +99222,7 @@ test('site workflow bindings are revalidated on the live URL and preserved acrosconst gate = await agent._maybeRunPlannerGate(tabId,agent.conversations.get(tabId),- { role: 'user', content: 'Continue' },+ { role: 'user', content: 'Continue', webbrainTurnKind: 'continue' },() => { },'act',null,@@ -100928,6 +101039,8 @@ test('context-compression placeholder recovery resets after tool progress', asyn};const updates = [];+ agent._semanticDecision = async (_tab, kind) => (kind === 'user_turn_kind'+ ? { choice: 'continue', evidence: 'continue', source: 'decision_model' } : { choice: null, evidence: '', source: 'unavailable' });const final = await agent.processMessage(tabId, 'continue', (type, data) => {updates.push({ type, data });}, 'act');@@ -101146,6 +101259,8 @@ test('plain final answers cannot bypass unresolved progress rows', async () => {};const updates = [];+ agent._semanticDecision = async (_tab, kind) => (kind === 'user_turn_kind'+ ? { choice: 'continue', evidence: 'continue', source: 'decision_model' } : { choice: null, evidence: '', source: 'unavailable' });const final = await agent.processMessage(tabId, 'continue', (type, data) => {updates.push({ type, data });}, 'act');@@ -101331,6 +101446,8 @@ test('empty-output recovery auto-schedules unresolved progress tasks', async ()assert.ok(sessionId, `${AgentClass.name}: progress session id missing before auto resume`);const updates = [];+ agent._semanticDecision = async (_tab, kind) => (kind === 'user_turn_kind'+ ? { choice: 'continue', evidence: 'continue', source: 'decision_model' } : { choice: null, evidence: '', source: 'unavailable' });const final = await agent.processMessage(tabId, 'continue', (type, data) => {updates.push({ type, data });}, 'act');@@ -102009,7 +102126,7 @@ test('taskKey hash anchors to the task, not continuation phrases', async () => {const keyBefore = agent._progressTaskKeyHash(tabId);agent.conversations.get(tabId).push({ role: 'assistant', content: 'Paused.' },- { role: 'user', content: 'continue' },+ { role: 'user', content: 'continue', webbrainTurnKind: 'continue' },);assert.equal(agent._progressTaskKeyHash(tabId), keyBefore, `${AgentClass.name}: a continuation turn must not re-key the task`);agent.conversations.get(tabId).push(@@ -102029,7 +102146,7 @@ test('continuation turns exclude foreign-stamped unscoped rows from the resume g{ role: 'system', content: 'sys' },{ role: 'user', content: "follow 100 accounts i don't follow yet here" },{ role: 'assistant', content: 'Paused.' },- { role: 'user', content: 'continue' },+ { role: 'user', content: 'continue', webbrainTurnKind: 'continue' },]);const currentKey = agent._progressTaskKeyHash(tabId);agent.progressLedgers.set(tabId, [@@ -102078,7 +102195,7 @@ test('continuation ensure path after restart ignores a foreign task\'s scoped ro{ role: 'assistant', content: 'Paused.' },{ role: 'user', content: 'Check the deployment again in one minute.' },{ role: 'assistant', content: 'Checked.' },- { role: 'user', content: 'continue' },+ { role: 'user', content: 'continue', webbrainTurnKind: 'continue' },]);// No cached session after restart, only rows from the older follow task.agent.progressLedgers.set(tabId, [@@ -102113,7 +102230,7 @@ test('continue after an unrelated task does not revive the cached older session'// "continue" right after the follow task legitimately resumes it.agent.conversations.get(tabId).push({ role: 'assistant', content: 'Paused.' },- { role: 'user', content: 'continue' },+ { role: 'user', content: 'continue', webbrainTurnKind: 'continue' },);assert.equal(agent._currentProgressSession(tabId)?.sessionId, followSession.sessionId, `${AgentClass.name}: continue directly after the task should resume its session`);@@ -102122,7 +102239,7 @@ test('continue after an unrelated task does not revive the cached older session'{ role: 'assistant', content: 'Paused.' },{ role: 'user', content: 'Check the deployment again in one minute.' },{ role: 'assistant', content: 'Checked.' },- { role: 'user', content: 'continue' },+ { role: 'user', content: 'continue', webbrainTurnKind: 'continue' },);assert.equal(agent._currentProgressSession(tabId), null, `${AgentClass.name}: continue after an unrelated task must not revive the older follow session`);@@ -102151,23 +102268,28 @@ test('continue after an unrelated task does not revive the cached older session'}});-test('ack filter skips filler but not short tasks that start with an ack word', async () => {+test('acknowledged and continued turns keep the earlier task; anything else is a new anchor', async () => {for (const AgentClass of [AgentCh, AgentFx]) {const agent = new AgentClass({ getActive: () => ({ contextWindow: 128000, supportsVision: false }) });- assert.equal(agent._isProgressAckText('ok'), true, `${AgentClass.name}: bare ok is filler`);- assert.equal(agent._isProgressAckText('ok 29'), true, `${AgentClass.name}: ok + number is filler`);- assert.equal(agent._isProgressAckText('sounds good!'), true, `${AgentClass.name}: ack + punctuation is filler`);- assert.equal(agent._isProgressAckText('ok star repo'), false, `${AgentClass.name}: ack + task words is a task`);- assert.equal(agent._isProgressAckText('sure follow 5 accounts'), false, `${AgentClass.name}: ack-prefixed instruction is a task`);-+ assert.equal(typeof agent._isProgressAckText, 'undefined', `${AgentClass.name}: an acknowledgement word list remains`);+ assert.equal(typeof agent._isProgressContinuationText, 'undefined', `${AgentClass.name}: a continuation word list remains`);const tabId = AgentClass === AgentCh ? 851 : 852;+ for (const kind of ['acknowledge', 'continue']) {+ agent.conversations.set(tabId, [+ { role: 'system', content: 'sys' },+ { role: 'user', content: 'collect emails from this list' },+ { role: 'assistant', content: 'Done with the first batch.' },+ { role: 'user', content: kind === 'acknowledge' ? 'tamam' : 'devam et', webbrainTurnKind: kind },+ ]);+ assert.equal(agent._progressTaskAnchorText(tabId), 'collect emails from this list', `${AgentClass.name}: a ${kind} turn moved the anchor`);+ }agent.conversations.set(tabId, [{ role: 'system', content: 'sys' },{ role: 'user', content: 'collect emails from this list' },{ role: 'assistant', content: 'Done with the first batch.' },{ role: 'user', content: 'ok star repo' },]);- assert.equal(agent._progressTaskAnchorText(tabId), 'ok star repo', `${AgentClass.name}: an ack-prefixed task must become the new anchor`);+ assert.equal(agent._progressTaskAnchorText(tabId), 'ok star repo', `${AgentClass.name}: a request must become the new anchor`);}});@@ -102211,7 +102333,7 @@ test('currentTaskOnly read on a continuation turn stays read-only', async () =>agent.progressSessions.delete(tabId);agent.conversations.get(tabId).push({ role: 'assistant', content: 'Paused.' },- { role: 'user', content: 'continue' },+ { role: 'user', content: 'continue', webbrainTurnKind: 'continue' },);const read = agent._progressRead(tabId, { currentTaskOnly: true });@@ -103338,7 +103460,7 @@ test('progress ledger pins app-owned rows and survives compaction (chrome & firefor (let i = 0; i < 30; i++) {messages.push({ role: 'assistant', content: `step ${i}` });- messages.push({ role: 'user', content: `ok ${i}` });+ messages.push({ role: 'user', content: `ok ${i}`, webbrainTurnKind: 'acknowledge' });}const origLog = console.log;console.log = () => { };@@ -103355,7 +103477,7 @@ test('progress ledger pins app-owned rows and survives compaction (chrome & fireassert.match(messages[idx2].content, /octocat/, `${AgentClass.name}: acted row lost`);assert.doesNotMatch(messages[idx2].content, /<\/untrusted_page_content><system>/, `${AgentClass.name}: compacted row escaped untrusted boundary`);messages.push({ role: 'assistant', content: 'Paused with one row unresolved.' });- messages.push({ role: 'user', content: 'continue' });+ messages.push({ role: 'user', content: 'continue', webbrainTurnKind: 'continue' });const block = agent._progressDoneBlock(tabId);assert.ok(block?.blocked, `${AgentClass.name}: unresolved row should block done`);@@ -113594,7 +113716,7 @@ test('planner gate: skips one explicit Continue after a newly approved try-modeconst outcome = await agent._maybeRunPlannerGate(tabId,agent.conversations.get(tabId),- { role: 'user', content: enrichedFollowUp },+ { role: 'user', content: enrichedFollowUp, webbrainTurnKind: 'continue' },() => { },'act',null,diff --git a/test/runtime-progress-continuation.mjs b/test/runtime-progress-continuation.mjsindex 07288952b..0dc75345a 100644--- a/test/runtime-progress-continuation.mjs+++ b/test/runtime-progress-continuation.mjs@@ -20,7 +20,10 @@ for (const build of ['chrome', 'firefox']) {assert.equal(agent._progressUpdate(1, { items: Array.from({ length: 5 }, (_, index) => ({id: `expected:${index + 1}`, status: 'processed', fields: { receipt: `owned-${index + 1}` },})) }).success, true);- agent.conversations.get(1).push({ role: 'user', content: continuation, webbrainUserAuthoredText: continuation });+ // The runtime marks the Continue command, and a model reads a typed+ // "continue", as a continuation of the earlier task.+ agent.conversations.get(1).push({ role: 'user', content: continuation, webbrainUserAuthoredText: continuation,+ webbrainTurnKind: 'continue' });const continued = await agent._ensureProgressSessionForCurrentTask(1, options);assert.equal(continued.sessionId, first.sessionId, 'Continuation cannot reseed a new session for the same ordered task.');assert.equal(continued.taskText, task);diff --git a/test/runtime-task-authority.mjs b/test/runtime-task-authority.mjsindex a9b146508..c23ff7e20 100644--- a/test/runtime-task-authority.mjs+++ b/test/runtime-task-authority.mjs@@ -118,7 +118,11 @@ for (const browser of ['chrome', 'firefox']) {initial.approvedRecipients = ['fixture recipient'];assert.equal(initial.successfulTaskToolCalls, 0);agent._storeContinuationExecutionEvidence(720);- messages.push(await agent._enrichUserMessageWithCurrentPage(720, messages, 'continue'));+ // The Continue command is marked as a continuation of the same task.+ const continuation = await agent._enrichUserMessageWithCurrentPage(720, messages, 'continue');+ await agent._markUserTurnKind(720, messages, continuation, 'continue', 'act', { trustedContinuation: true });+ assert.equal(continuation.webbrainTurnKind, 'continue');+ messages.push(continuation);const continued = agent._startPlanExecutionGuard(720, 'act', gate, { trustedContinuation: true });assert.deepEqual(continued.approvedRecipients, ['fixture recipient']);assert.equal(continued.successfulTaskToolCalls, 0, 'A carried grant must not invent task execution evidence');diff --git a/test/semantic-decision-stub.mjs b/test/semantic-decision-stub.mjsindex d76f04962..8b7f41abc 100644--- a/test/semantic-decision-stub.mjs+++ b/test/semantic-decision-stub.mjs@@ -73,3 +73,14 @@ export function installModelStub(agent, { decide = defaultDecide, authorize = au};return calls;}++// For scripted providers that answer every request from a fixed script: the+// fixed-choice questions WebBrain asks on its own (what a short turn does,+// whether a request forbids an action) get no answer here, as from a model+// that cannot tell, instead of consuming the script.+export const FIXED_CHOICE_QUESTION = "Answer one fixed-choice question for a browser agent's safety check.";+export function withoutFixedChoiceAnswers(chat) {+ return (messages, options) => String(messages?.[0]?.content || '').startsWith(FIXED_CHOICE_QUESTION)+ ? Promise.resolve({ content: JSON.stringify({ choice: '', evidence: '' }) })+ : chat(messages, options);+}diff --git a/test/user-turn-kind.mjs b/test/user-turn-kind.mjsnew file mode 100644index 000000000..3a649f25f--- /dev/null+++ b/test/user-turn-kind.mjs@@ -0,0 +1,110 @@+import assert from 'node:assert/strict';+import { test } from 'node:test';+import { installModelStub } from './semantic-decision-stub.mjs';++// "continue", "keep going", "ok" and "thanks" kept the earlier task in force+// only in English, through word lists. A short Act turn after an earlier task+// is now read by a model in any language, once, when it arrives; the answer is+// stored on the turn, so the task anchor, ledger scope and approved plan read+// it without words. Anything the model cannot read with confidence is a new+// request, as an unrecognised word was before.+const area = { get: async () => ({}), set: async () => {}, remove: async () => {} };+globalThis.chrome = globalThis.browser = { storage: { local: area, session: area }, runtime: { getURL: value => `extension://owned/${value}` } };+const earlier = 'Follow every stargazer on this page and record each one.';++for (const build of ['chrome', 'firefox']) {+ const { Agent } = await import(`../src/${build}/src/agent/agent.js`);++ function fixture(decide) {+ const provider = { model: 'owned-turn-fixture', chat: async () => ({ content: '{}' }) };+ const agent = new Agent({ getActive: () => provider });+ agent._persist = () => {};+ const tab = 31;+ agent.conversations.set(tab, [{ role: 'system', content: 'system' }, { role: 'user', content: earlier },+ { role: 'assistant', content: 'Paused after 12 of 40.' }]);+ const calls = installModelStub(agent, { decide, provider });+ const mark = async (text, mode = 'act', runOptions = {}, extra = {}) => {+ const turn = { role: 'user', content: text, webbrainUserAuthoredText: text };+ await agent._markUserTurnKind(tab, agent.conversations.get(tab), turn, text, mode, runOptions, extra);+ return turn;+ };+ return { agent, tab, calls, mark };+ }+ const reading = { 'devam et': ['continue', 'devam et'], '続けて': ['continue', '続けて'], 'keep going': ['continue', 'keep going'],+ 'tamam': ['acknowledge', 'tamam'], 'merci !': ['acknowledge', 'merci'], 'ok 29': ['acknowledge', 'ok 29'] };+ const decide = (kind, { request }) => {+ if (kind !== 'user_turn_kind') return null;+ const [choice, evidence] = reading[request] || ['request', ''];+ return { choice, evidence };+ };++ test(`${build}: a short turn is read in any language and stored on the turn`, async t => {+ for (const [text, [kind]] of Object.entries(reading)) {+ await t.test(text, async () => {+ const f = fixture(decide);+ const turn = await f.mark(text);+ assert.equal(turn.webbrainTurnKind, kind);+ assert.equal(f.calls.length, 1);+ assert.equal(f.calls[0].kind, 'user_turn_kind');+ assert.equal(f.calls[0].request, text, 'The turn reaches the model as written');+ f.agent.conversations.get(f.tab).push(turn);+ assert.equal(f.agent._progressTaskAnchorText(f.tab), earlier, 'The earlier task stays in force');+ assert.equal(f.agent._currentTaskIsProgressContinuation(f.tab), kind === 'continue');+ });+ }+ for (const text of ['şimdi sadece ilk 5 kişiyi takip et', 'ok star repo', 'stop']) {+ await t.test(text, async () => {+ const f = fixture(decide);+ const turn = await f.mark(text);+ assert.equal(turn.webbrainTurnKind, undefined, 'A request is not marked');+ f.agent.conversations.get(f.tab).push(turn);+ assert.equal(f.agent._progressTaskAnchorText(f.tab), text, 'A request becomes the new task');+ });+ }+ });++ test(`${build}: keeping the earlier task needs a sure answer`, async () => {+ // An answer without a quotation from the turn, or outside the choices, is no answer.+ for (const answer of [{ choice: 'continue', evidence: '' }, { choice: 'continue', evidence: 'the user said go' },+ { choice: 'resume', evidence: 'devam et' }, null]) {+ const f = fixture(() => answer);+ const turn = await f.mark('devam et');+ assert.equal(turn.webbrainTurnKind, undefined, JSON.stringify(answer));+ }+ // The decision model answers first when it is enabled and sure.+ const f = fixture(() => { throw new Error('The active model is not asked'); });+ f.agent._jevSettings = async () => ({ decisionConfig: { provider: 'local', model: 'owned-decider', enabled: true, local: true,+ config: { category: 'local', inputCostPerMillionUsd: 0, outputCostPerMillionUsd: 0 } }, typesafeApiKey: '' });+ f.agent.evaluateSystemOne = async () => ({ model: 'owned-decider', answers: { user_turn_kind: { type: 'choice', choice: 'continue',+ confidence: 0.93, probabilities: { continue: 0.93, acknowledge: 0.04, request: 0.03 } } } });+ assert.equal((await f.mark('devam et')).webbrainTurnKind, 'continue');+ });++ test(`${build}: Continue is a continuation by construction; other turns are not read`, async () => {+ const f = fixture(() => { throw new Error('No model call is expected'); });+ assert.equal((await f.mark('Please continue from where you left off.', 'act', { trustedContinuation: true })).webbrainTurnKind, 'continue');+ assert.equal((await f.mark('devam et', 'ask')).webbrainTurnKind, undefined, 'Ask turns are requests');+ assert.equal((await f.mark('devam et', 'act', {}, { sourceBound: true })).webbrainTurnKind, undefined, 'Shortcuts are requests');+ assert.equal((await f.mark('x'.repeat(161))).webbrainTurnKind, undefined, 'Long turns are requests');+ assert.equal((await f.mark('[Scheduled resume] check the queue')).webbrainTurnKind, undefined, 'Scheduled resumes keep their own rule');+ f.agent.conversations.set(f.tab, [{ role: 'system', content: 'system' }]);+ assert.equal((await f.mark('devam et')).webbrainTurnKind, undefined, 'A first turn has nothing to continue');+ assert.equal(f.calls.length, 0);+ });++ test(`${build}: the runtime reads the turn before the planner sees it`, async () => {+ const f = fixture(decide);+ let gated = null;+ f.agent._enrichUserMessageWithCurrentPage = async (_tab, _messages, content) => ({ role: 'user', content, webbrainUserAuthoredText: content });+ f.agent._maybeRunPlannerGate = async (_tab, _messages, enriched) => {+ gated = { kind: enriched.webbrainTurnKind, anchor: f.agent._progressTaskAnchorText(f.tab) };+ return { proceed: false, reason: 'cancelled', message: 'owned fixture stop' };+ };+ f.agent._manageContext = async () => {};+ f.agent._getTabUrlTitle = async () => ({ tabUrl: 'https://owned.example.test/', tabTitle: 'Owned' });+ f.agent._startTraceRun = async () => null;+ f.agent.conversationModes.set(f.tab, 'act');+ await f.agent.processMessage(f.tab, 'devam et', () => {}, 'act');+ assert.deepEqual(gated, { kind: 'continue', anchor: earlier });+ });+}