Skip to content

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

Recognize the dispatched deletion receipt when choosing the caveat

Claudef4aaabd60b06
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index e861cebfd..587b8f558 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -40889,12 +40889,15 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// caveat. The one-nudge budget and run-ending statuses below are the
// strict path.
// The unverified action is a deletion only when deletions are all that was
- // dispatched: an ordinary form submission leaves no resource-mutation
- // record, but it does leave the current submit receipt.
+ // dispatched. A dispatched deletion is also the current submit receipt
+ // (_recordCompletionSubmitState keeps both), so that receipt is fine; a
+ // later ordinary form submission replaces it with one that is not a
+ // deletion and leaves no resource-mutation record of its own.
+ const currentReceipt = missingRequiredSubmission ? this._currentCompletionSubmitState(tabId) : null;
const missingDeletion = missingRequiredSubmission
&& Array.isArray(state.resourceMutationDispatches) && state.resourceMutationDispatches.length > 0
&& state.resourceMutationDispatches.every(attempt => attempt?.mutationKind === 'delete')
- && this._currentCompletionSubmitState(tabId)?.dispatched !== true;
+ && (currentReceipt?.dispatched !== true || currentReceipt.mutationKind === 'delete');
const advisory = this._planGuardAdvisory(tabId, state, { viaDone, looksPlanOnly, runtimeModeContradiction,
structuredPlan: structuredPlan
|| (state.allowsPlannerShapedResult !== true && this._isPlannerShapedJson(content)),
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 1b7a8b1e0..b02f6fa97 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -37632,12 +37632,15 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// caveat. The one-nudge budget and run-ending statuses below are the
// strict path.
// The unverified action is a deletion only when deletions are all that was
- // dispatched: an ordinary form submission leaves no resource-mutation
- // record, but it does leave the current submit receipt.
+ // dispatched. A dispatched deletion is also the current submit receipt
+ // (_recordCompletionSubmitState keeps both), so that receipt is fine; a
+ // later ordinary form submission replaces it with one that is not a
+ // deletion and leaves no resource-mutation record of its own.
+ const currentReceipt = missingRequiredSubmission ? this._currentCompletionSubmitState(tabId) : null;
const missingDeletion = missingRequiredSubmission
&& Array.isArray(state.resourceMutationDispatches) && state.resourceMutationDispatches.length > 0
&& state.resourceMutationDispatches.every(attempt => attempt?.mutationKind === 'delete')
- && this._currentCompletionSubmitState(tabId)?.dispatched !== true;
+ && (currentReceipt?.dispatched !== true || currentReceipt.mutationKind === 'delete');
const advisory = this._planGuardAdvisory(tabId, state, { viaDone, looksPlanOnly, runtimeModeContradiction,
structuredPlan: structuredPlan
|| (state.allowsPlannerShapedResult !== true && this._isPlannerShapedJson(content)),
diff --git a/test/guard-advisory-completion.mjs b/test/guard-advisory-completion.mjs
index d20ef0f58..451354503 100644
--- a/test/guard-advisory-completion.mjs
+++ b/test/guard-advisory-completion.mjs
@@ -1019,9 +1019,11 @@ for (const build of ['chrome', 'firefox']) {
// A deletion is described as one, so the caveat never speaks of a
// "submission" the user did not make.
- await refusedOnceThenAccepted(Agent, planCase({ requiresStateChange: true, requiresSubmission: true }, guard => {
+ // As in a real run, the dispatched deletion is also the current submit receipt.
+ await refusedOnceThenAccepted(Agent, planCase({ requiresStateChange: true, requiresSubmission: true }, (guard, h) => {
guard.successfulConsequentialToolCalls = 1; guard.successfulTaskToolCalls = 1; guard.evidenceTaskKey = guard.taskKey;
- guard.resourceMutationDispatches = [{ mutationKind: 'delete', resourceUrl: 'https://mastoturk.org/@owned/1' }];
+ guard.resourceMutationDispatches = [{ mutationKind: 'delete', resourceUrl: 'https://mastoturk.org/@owned/1', actionSequence: 3 }];
+ h.agent._completionSubmitStates.set(h.tab, { dispatched: true, mutationKind: 'delete', actionSequence: 3, taskKey: guard.taskKey });
}), { summary: 'Deleted the post.', outcome: 'success' }, 'I couldn\'t confirm that the deletion took effect.', `${build} deletion`);
// With an ordinary form submission also dispatched, the unverified action