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
Ask cards: an unclear commit action is not asked about while a message is requested
Barack Sokullu8c60af851a34
diff --git a/docs/guards.md b/docs/guards.mdindex 9f21f5069..50b7645df 100644--- a/docs/guards.md+++ b/docs/guards.md@@ -110,7 +110,7 @@ When a guard cannot verify a consequential step and its `onCannotDecide` is| Guard | Asks when | The card shows ||---|---|---|| `github-commit-evidence-binding` | The file editor was replaced but could not be read back exactly (CodeMirror), and path, branch and commit message bind | The editor's text |-| `github-commit-split-write-required` | A script, Enter or `set_field` submit that may or may not commit, when a commit click would be allowed | The editor's text |+| `github-commit-split-write-required` | A script, Enter or `set_field` submit that may or may not commit, when a commit click would be allowed and the request names no commit message (one is proven only before the commit) | The editor's text || `social-publication-draft-quality` | The X/Bluesky draft's text does not read back as requested or could not be read, when the user asked to publish (the publication audit still runs). Media that does not match and a composer that was not read completely still refuse: the card shows only the text | The composer's text || `steer-prior-submission-target-unresolved` | After a correction, a submit-capable control the probe could not identify | Nothing (check the page) || `clickax-task-click-lock` (hard, Chrome) | An earlier trusted click on the same target may have landed and was never verified | Nothing (check the page) |diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 46230b23c..f9a02c98b 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -3358,12 +3358,17 @@ export class Agent extends LoopDetector {// and message binding is in place, verified or approved by the user),// the user decides on WebBrain's card, which shows the editor's text.// One answer covers this one tool call (_unverifiedStepApproval).+ // A requested commit message is proven only before the commit, and+ // this action could rewrite it while it commits: no card makes that+ // proof cover it, so while the request names one it keeps refusing.if (inconclusiveSubmitCapable&& this._guardOutcome('github-commit-split-write-required', { decided: false }) === 'ask') {const pageUrl = await this._currentUrl(tabId);await this._refreshGithubTextReplacementProofs(tabId, pageUrl);const binding = this._workflowSubmitBindingForAttempt(tabId, pageUrl, {}, detectedSubmit);- if (binding?.metadataRequirementsIncomplete !== true && binding?.githubFileCommit) {+ const messageRequested = (Array.isArray(binding?.metadataRequirements) ? binding.metadataRequirements : [])+ .some(requirement => requirement?.field === 'commit_message');+ if (binding?.metadataRequirementsIncomplete !== true && binding?.githubFileCommit && !messageRequested) {const stepKey = this._sha256TextSync(JSON.stringify(['github-commit-split-write-required',this._normalizeUrl(pageUrl), this._formValidationActionKey(name, args) || name, this._taskTokens.get(tabId) || '']));const ask = { guardId: 'github-commit-split-write-required', hard: false, action: 'commit', reason: 'submit_unclear',diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex 8882f63ad..7ce901b66 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -2915,12 +2915,17 @@ export class Agent extends LoopDetector {// and message binding is in place, verified or approved by the user),// the user decides on WebBrain's card, which shows the editor's text.// One answer covers this one tool call (_unverifiedStepApproval).+ // A requested commit message is proven only before the commit, and+ // this action could rewrite it while it commits: no card makes that+ // proof cover it, so while the request names one it keeps refusing.if (inconclusiveSubmitCapable&& this._guardOutcome('github-commit-split-write-required', { decided: false }) === 'ask') {const pageUrl = await this._currentUrl(tabId);await this._refreshGithubTextReplacementProofs(tabId, pageUrl);const binding = this._workflowSubmitBindingForAttempt(tabId, pageUrl, {}, detectedSubmit);- if (binding?.metadataRequirementsIncomplete !== true && binding?.githubFileCommit) {+ const messageRequested = (Array.isArray(binding?.metadataRequirements) ? binding.metadataRequirements : [])+ .some(requirement => requirement?.field === 'commit_message');+ if (binding?.metadataRequirementsIncomplete !== true && binding?.githubFileCommit && !messageRequested) {const stepKey = this._sha256TextSync(JSON.stringify(['github-commit-split-write-required',this._normalizeUrl(pageUrl), this._formValidationActionKey(name, args) || name, this._taskTokens.get(tabId) || '']));const ask = { guardId: 'github-commit-split-write-required', hard: false, action: 'commit', reason: 'submit_unclear',diff --git a/test/guard-ask-cards.mjs b/test/guard-ask-cards.mjsindex bb48962eb..ae1451b57 100644--- a/test/guard-ask-cards.mjs+++ b/test/guard-ask-cards.mjs@@ -196,7 +196,8 @@ for (const { build, Agent, adapters, Scheduler } of builds) {// The owner's case: the blog post went into GitHub's CodeMirror editor as a// full replacement, the readback (rendered text) could not verify it, and// path, branch and commit message bind.- async function githubFixture({ strict = false, body = POST_BODY, live = body, message = 'Publish the post' } = {}) {+ async function githubFixture({ strict = false, body = POST_BODY, live = body, message = 'Publish the post',+ requestMessage = true } = {}) {const provider = { name: 'ask card test', model: 'test', promptTier: 'full', contextWindow: 128000,supportsTools: true, supportsVision: false, chat: async () => ({ content: '' }) };const agent = new Agent({ getActive: () => provider, getProvider: () => provider, getVisionProvider: async () => null });@@ -209,7 +210,7 @@ for (const { build, Agent, adapters, Scheduler } of builds) {assert.equal(siteWorkflow?.job?.id, 'edit-file-and-commit');const guard = { enabled: true, taskKey: `key-${tab}`, siteWorkflow,workflowMetadataRequirements: [{ field: 'path', value: 'docs/post.md' }, { field: 'branch', value: 'main' },- { field: 'commit_message', value: message }],+ ...(requestMessage ? [{ field: 'commit_message', value: message }] : [])],workflowMetadataRequirementsResolved: true, workflowMetadataRequirementsIncomplete: false };agent._planExecutionGuards.set(tab, guard);agent._lastAxScopes.set(tab, { documentToken: 'doc', pageUrl: EDIT_URL });@@ -544,8 +545,19 @@ for (const { build, Agent, adapters, Scheduler } of builds) {// ββ github-commit-split-write-required βββββββββββββββββββββββββββββββββtest(`${build}: an action that may or may not commit asks when a commit is otherwise allowed`, async () => {+ // With a requested commit message there is no card: the message is+ // proven only before the commit, and this action could rewrite it.+ {+ const { agent, tab } = await githubFixture();+ const editorTarget = agent._textMutationTarget(tab, 'set_field', { ref_id: 'ref_editor' });+ agent._unverifiedTextWrites.delete(tab);+ agent._verifiedTextReplacements.get(tab).set(editorTarget.key, await agent._verifiedTextReplacementRecord(tab, editorTarget, POST_BODY, EDITOR_META));+ const block = await agent._workflowPreSubmitDispatchBlock(tab, 'execute_js', { code: 'void 0' }, null);+ assert.equal(block.splitWriteRequired, true);+ assert.equal(block.unverifiedStepConfirmation, undefined, 'a requested message keeps the split');+ }for (const strict of [false, true]) {- const { agent, tab } = await githubFixture({ strict });+ const { agent, tab } = await githubFixture({ strict, requestMessage: false });// A verified editor proof: the commit binding holds.const editorTarget = agent._textMutationTarget(tab, 'set_field', { ref_id: 'ref_editor' });agent._unverifiedTextWrites.delete(tab);@@ -575,7 +587,7 @@ for (const { build, Agent, adapters, Scheduler } of builds) {});test(`${build}: a split-write answer covers only the editor text the user saw`, async () => {- const { agent, tab, page } = await githubFixture();+ const { agent, tab, page } = await githubFixture({ requestMessage: false });// A verified editor proof: the commit binding holds for POST_BODY.const editorTarget = agent._textMutationTarget(tab, 'set_field', { ref_id: 'ref_editor' });agent._unverifiedTextWrites.delete(tab);@@ -617,7 +629,7 @@ for (const { build, Agent, adapters, Scheduler } of builds) {assert.equal(resolved, null, 'unchanged text goes ahead once');assert.ok((await rerun()).unverifiedStepConfirmation, 'one answer covers one action');// An editor that cannot be read cannot be approved.- const unreadable = await githubFixture();+ const unreadable = await githubFixture({ requestMessage: false });const target = unreadable.agent._textMutationTarget(unreadable.tab, 'set_field', { ref_id: 'ref_editor' });unreadable.agent._unverifiedTextWrites.delete(unreadable.tab);unreadable.agent._verifiedTextReplacements.get(unreadable.tab).set(target.key,@@ -630,7 +642,7 @@ for (const { build, Agent, adapters, Scheduler } of builds) {});test(`${build}: inside one call, a split-write answer holds for every re-run of the call's checks`, async () => {- const { agent, tab } = await githubFixture();+ const { agent, tab } = await githubFixture({ requestMessage: false });const editorTarget = agent._textMutationTarget(tab, 'set_field', { ref_id: 'ref_editor' });agent._unverifiedTextWrites.delete(tab);agent._verifiedTextReplacements.get(tab).set(editorTarget.key, await agent._verifiedTextReplacementRecord(tab, editorTarget, POST_BODY, EDITOR_META));