Skip to content

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

Remember only resolved submissions; any user answer lifts a decline

Claude9241f84410ac
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index a872d3386..3e568c9ed 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -16652,13 +16652,15 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
} else {
// The user already said no to this exact submission (same form,
// same values) in this turn: refuse it again without a new card.
- const declineKey = submitActionKey(submitConfirmation, submitConfirmation.url);
- if (this.permissions?.isSubmissionDeclined?.(declineKey, tabId) === true) {
+ // Only a submission WebBrain resolved has an identity; a script or
+ // WebMCP callback, or a control with no form, asks every time.
+ const declineKey = this._declinableSubmissionKey(fnName, submitConfirmation);
+ if (declineKey && this.permissions?.isSubmissionDeclined?.(declineKey, tabId) === true) {
choice = 'deny';
alreadyDeclined = true;
} else {
choice = await this._promptSubmitConfirmation(tabId, submitConfirmation, onUpdate);
- if (choice === 'deny') this.permissions?.declineSubmission?.(declineKey, tabId);
+ if (choice === 'deny' && declineKey) this.permissions?.declineSubmission?.(declineKey, tabId);
}
}
if (this._hasPendingSteering(tabId) && !this._checkAbort(tabId)) return skipSteeredPermissionWait(toolIndex);
@@ -21874,10 +21876,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// The time the user took to answer one of WebBrain's own cards does not
// age the page observation the pending action was decided on.
this._noteClarifyHeld(tabId, entry);
- // The user answering any card is the user speaking again: a submission
- // declined earlier in the turn may be asked about once more. A timeout's
- // or Instant's answer is WebBrain's, not the user's.
- if (source === 'user') this.permissions?.clearDeclinedSubmissions?.(tabId);
+ // The user answering any card (an option, typed text, a slash command,
+ // a Cloud API answer) is the user speaking again: a submission declined
+ // earlier in the turn may be asked about once more. A timeout's or
+ // Instant's answer is WebBrain's, not the user's.
+ if (source !== 'timeout' && source !== 'auto') this.permissions?.clearDeclinedSubmissions?.(tabId);
this._settleClarification(entry, { answer, source });
return true;
}
@@ -32443,6 +32446,17 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return null;
}
+ // The identity a declined submission is remembered by in a turn, or ''
+ // when WebBrain did not resolve one: a script or WebMCP callback, or a
+ // control whose form, fields and action it could not read.
+ _declinableSubmissionKey(toolName, submitInfo) {
+ if (!submitInfo || toolName === 'execute_js' || toolName === 'execute_webmcp_tool') return '';
+ const resolved = (Array.isArray(submitInfo.changedFields) && submitInfo.changedFields.length > 0)
+ || (Array.isArray(submitInfo.fields) && submitInfo.fields.length > 0)
+ || !!(submitInfo.actionUrl || submitInfo.action);
+ return resolved ? submitActionKey(submitInfo, submitInfo.url) : '';
+ }
+
_fallbackSubmitConfirmationInfo(host, tool, reason, summary = '') {
const normalizedHost = normalizeHost(host || '') || String(host || '').trim() || 'this site';
return {
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 4d892365e..bfcaea9ac 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -14828,13 +14828,15 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
} else {
// The user already said no to this exact submission (same form,
// same values) in this turn: refuse it again without a new card.
- const declineKey = submitActionKey(submitConfirmation, submitConfirmation.url);
- if (this.permissions?.isSubmissionDeclined?.(declineKey, tabId) === true) {
+ // Only a submission WebBrain resolved has an identity; a script or
+ // WebMCP callback, or a control with no form, asks every time.
+ const declineKey = this._declinableSubmissionKey(fnName, submitConfirmation);
+ if (declineKey && this.permissions?.isSubmissionDeclined?.(declineKey, tabId) === true) {
choice = 'deny';
alreadyDeclined = true;
} else {
choice = await this._promptSubmitConfirmation(tabId, submitConfirmation, onUpdate);
- if (choice === 'deny') this.permissions?.declineSubmission?.(declineKey, tabId);
+ if (choice === 'deny' && declineKey) this.permissions?.declineSubmission?.(declineKey, tabId);
}
}
if (this._hasPendingSteering(tabId) && !this._checkAbort(tabId)) return skipSteeredPermissionWait(toolIndex);
@@ -18915,10 +18917,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// The time the user took to answer one of WebBrain's own cards does not
// age the page observation the pending action was decided on.
this._noteClarifyHeld(tabId, entry);
- // The user answering any card is the user speaking again: a submission
- // declined earlier in the turn may be asked about once more. A timeout's
- // or Instant's answer is WebBrain's, not the user's.
- if (source === 'user') this.permissions?.clearDeclinedSubmissions?.(tabId);
+ // The user answering any card (an option, typed text, a slash command,
+ // a Cloud API answer) is the user speaking again: a submission declined
+ // earlier in the turn may be asked about once more. A timeout's or
+ // Instant's answer is WebBrain's, not the user's.
+ if (source !== 'timeout' && source !== 'auto') this.permissions?.clearDeclinedSubmissions?.(tabId);
this._settleClarification(entry, { answer, source });
return true;
}
@@ -29431,6 +29434,17 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return null;
}
+ // The identity a declined submission is remembered by in a turn, or ''
+ // when WebBrain did not resolve one: a script or WebMCP callback, or a
+ // control whose form, fields and action it could not read.
+ _declinableSubmissionKey(toolName, submitInfo) {
+ if (!submitInfo || toolName === 'execute_js' || toolName === 'execute_webmcp_tool') return '';
+ const resolved = (Array.isArray(submitInfo.changedFields) && submitInfo.changedFields.length > 0)
+ || (Array.isArray(submitInfo.fields) && submitInfo.fields.length > 0)
+ || !!(submitInfo.actionUrl || submitInfo.action);
+ return resolved ? submitActionKey(submitInfo, submitInfo.url) : '';
+ }
+
_fallbackSubmitConfirmationInfo(host, tool, reason, summary = '') {
const normalizedHost = normalizeHost(host || '') || String(host || '').trim() || 'this site';
return {
diff --git a/test/run.js b/test/run.js
index ecd6f8d7a..3a3c2d7dd 100644
--- a/test/run.js
+++ b/test/run.js
@@ -82652,7 +82652,9 @@ test('a declined submission is not asked again in the same turn', async () => {
email = '[email protected]';
const userEntry = { resolve: () => { }, ts: Date.now() };
agent._pendingClarifications.set(tabId, new Map([['asked', userEntry]]));
- agent.submitClarifyResponse(tabId, 'asked', 'Yes, submit it', 'user');
+ // The side panel sends the source of the user's answer: an option, text,
+ // a slash command or a Cloud API answer.
+ agent.submitClarifyResponse(tabId, 'asked', 'Yes, submit it', 'option');
await submit('after-user-answer');
assert.equal(prompts, 3, `${AgentClass.name}: the user's own answer on a later card asks again`);
@@ -82660,6 +82662,28 @@ test('a declined submission is not asked again in the same turn', async () => {
await submit('new-turn');
assert.equal(prompts, 4, `${AgentClass.name}: a new turn asks again`);
assert.equal(executed, 0, `${AgentClass.name}: nothing declined was submitted`);
+
+ // A script has no form identity: each run of one asks on its own card.
+ agent._detectLikelySubmitAction = async () => agent._fallbackSubmitConfirmationInfo('host.com', 'execute_js', 'execute_js can run page JavaScript');
+ const script = async (id, code) => {
+ const messages = [];
+ await agent._executeToolBatch(
+ tabId,
+ [{ id, function: { name: 'execute_js', arguments: JSON.stringify({ code }) } }],
+ messages,
+ () => { },
+ { supportsVision: false },
+ '',
+ new Set(['execute_js']),
+ 1,
+ );
+ return messages;
+ };
+ agent.conversationModes.set(tabId, 'dev');
+ const before = prompts;
+ await script('script-1', 'document.forms[0].submit()');
+ await script('script-2', 'document.forms[1].submit()');
+ assert.equal(prompts, before + 2, `${AgentClass.name}: a declined script made a different script skip its card`);
}
});