Skip to content

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

Keep an earlier deletion of unknown result holding a deletion after a correction

Barack Sokullu796c9b4d865c
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 03d2fb922..a939edfee 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -7372,14 +7372,18 @@ export class Agent extends LoopDetector {
} else if (formCommit && priorForm && priorForm === detected.actionUrl && inPlace
&& this._steeringPriorEffectObserved(tabId, prior)) observedKind = 'form_observation';
}
- // A deletion cannot repeat the earlier submission or sit beside it, so an
- // earlier result WebBrain cannot match does not hold it back: a Mastodon
- // post, for one, sits on a timeline that WebBrain does not match to the
- // form it was sent from. Which item to delete is still decided below, by
- // the latest request or by the user on WebBrain's own card, and nothing
- // is recorded as reconciled, so a later post or commit is still held.
+ // A deletion cannot repeat an earlier post or commit or sit beside it, so
+ // an earlier result WebBrain cannot match does not hold it back: a
+ // Mastodon post, for one, sits on a timeline that WebBrain does not match
+ // to the form it was sent from. Which item to delete is still decided
+ // below, by the latest request or by the user on WebBrain's own card, and
+ // nothing is recorded as reconciled, so a later post or commit is still
+ // held. An earlier attempt that may itself have deleted something still
+ // holds a deletion: this one could repeat it, and a run rebuilt from the
+ // conversation keeps no dispatch record that would catch the repeat.
const unreconciled = prior.dispatched !== true || (matching.length !== 1 && !deletedVerifiedResource && !observedKind);
- if (unreconciled && !deletion) {
+ const earlierDeletion = archivedAttempts.some(receipt => receipt.mutationKind === 'delete');
+ if (unreconciled && !(deletion && !earlierDeletion)) {
return blocked('prior_effect_unreconciled', publication && !crossPlatform
? 'The earlier post from before the latest correction has not been matched yet. Read it on this platform (its permalink or the account\'s recent posts), then retry; do not repeat an uncertain publication.'
: publication && siteCrossPlatform && prior.mutationKind !== 'delete'
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 36d70f662..e10e7a690 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -6918,14 +6918,18 @@ export class Agent extends LoopDetector {
} else if (formCommit && priorForm && priorForm === detected.actionUrl && inPlace
&& this._steeringPriorEffectObserved(tabId, prior)) observedKind = 'form_observation';
}
- // A deletion cannot repeat the earlier submission or sit beside it, so an
- // earlier result WebBrain cannot match does not hold it back: a Mastodon
- // post, for one, sits on a timeline that WebBrain does not match to the
- // form it was sent from. Which item to delete is still decided below, by
- // the latest request or by the user on WebBrain's own card, and nothing
- // is recorded as reconciled, so a later post or commit is still held.
+ // A deletion cannot repeat an earlier post or commit or sit beside it, so
+ // an earlier result WebBrain cannot match does not hold it back: a
+ // Mastodon post, for one, sits on a timeline that WebBrain does not match
+ // to the form it was sent from. Which item to delete is still decided
+ // below, by the latest request or by the user on WebBrain's own card, and
+ // nothing is recorded as reconciled, so a later post or commit is still
+ // held. An earlier attempt that may itself have deleted something still
+ // holds a deletion: this one could repeat it, and a run rebuilt from the
+ // conversation keeps no dispatch record that would catch the repeat.
const unreconciled = prior.dispatched !== true || (matching.length !== 1 && !deletedVerifiedResource && !observedKind);
- if (unreconciled && !deletion) {
+ const earlierDeletion = archivedAttempts.some(receipt => receipt.mutationKind === 'delete');
+ if (unreconciled && !(deletion && !earlierDeletion)) {
return blocked('prior_effect_unreconciled', publication && !crossPlatform
? 'The earlier post from before the latest correction has not been matched yet. Read it on this platform (its permalink or the account\'s recent posts), then retry; do not repeat an uncertain publication.'
: publication && siteCrossPlatform && prior.mutationKind !== 'delete'
diff --git a/test/guards-steering-receipts.mjs b/test/guards-steering-receipts.mjs
index b4b438d73..963cf8409 100644
--- a/test/guards-steering-receipts.mjs
+++ b/test/guards-steering-receipts.mjs
@@ -1046,6 +1046,30 @@ for (const build of ['chrome', 'firefox']) {
} finally { declined.close(); }
});
+ test(`${build}: after a correction, an earlier deletion whose result is unknown still holds a deletion`, async () => {
+ // The earlier attempt was itself this deletion (the receipt Mastodon's
+ // confirmation records), and its response was lost.
+ const h = await fixture('delete my test post on mastoturk.org', { pageUrl: timelineHome });
+ try {
+ h.agent._recordCompletionSubmitAttempt(h.tab, { ...timelineDelete, isSubmit: true }, 'click_ax', { ref_id: 'ref_7' }, timelineHome, timelineHome,
+ { success: true, dispatched: true }, 'home-doc', 'home-doc');
+ const guard = await h.steer('now delete it');
+ h.read(timelineHome);
+ assert.equal(guard.steeringPriorSubmission?.mutationKind, 'delete');
+ assert.deepEqual(guard.resourceMutationDispatches || [], [], 'As in a run rebuilt from the conversation');
+ assert.equal((await h.check(timelineDelete))?.actionGuard?.reason, 'prior_effect_unreconciled');
+ assert.equal(h.decisions('deletion_request').length, 0, 'The repeat is not put to the deletion question');
+ assert.notEqual(h.steeringBlock(timelineDelete), null);
+ } finally { h.close(); }
+ // A deletion archived at an earlier correction holds it the same way.
+ const archived = await timelinePostThen('now delete it');
+ try {
+ archived.guard.steeringMutationReceipts = [...(archived.guard.steeringMutationReceipts || []),
+ { dispatched: true, actionSequence: 2, mutationKind: 'delete', actionResource: { complete: true, url: timelinePost } }];
+ assert.equal((await archived.check(timelineDelete))?.actionGuard?.reason, 'prior_effect_unreconciled');
+ } finally { archived.close(); }
+ });
+
test(`${build}: after a correction an unidentified target says so; commits still need reconciliation`, async () => {
const h = await fixture('Save the owned profile name as Original.');
try {
diff --git a/test/quality/mastodon-delete-after-correction-mv3.mjs b/test/quality/mastodon-delete-after-correction-mv3.mjs
index 8a732444c..2cc6c4df7 100644
--- a/test/quality/mastodon-delete-after-correction-mv3.mjs
+++ b/test/quality/mastodon-delete-after-correction-mv3.mjs
@@ -267,7 +267,8 @@ try {
assert.equal((await message('set_active_provider', { providerId: 'openrouter' })).ok, true);
await worker.evaluate(() => { afterCorrectionAgent.clarifyTimeoutSec = -1; });
page = await context.newPage(); await page.goto('https://mastoturk.org/home');
- tabId = await settings.evaluate(async () => (await chrome.tabs.query({})).find(tab => tab.url.startsWith('https://mastoturk.org'))?.id);
+ tabId = await settings.evaluate(async () => (await chrome.tabs.query({}))
+ .find(tab => { try { return new URL(tab.url).origin === 'https://mastoturk.org'; } catch { return false; } })?.id);
// WebBrain's own cards are answered "Go ahead" ('once'); every card is recorded.
let answering = true;
const answerer = (async () => {
@@ -283,8 +284,14 @@ try {
await new Promise(resolve => setTimeout(resolve, 100));
}
})();
- const result = await message('chat', { tabId, text: request, mode: 'act', requestId: 'owned-delete-after-correction', locale: 'en' });
- answering = false; await answerer;
+ // The poller stops however the run ends, so a failed run fails the test
+ // instead of leaving it waiting.
+ let result;
+ try {
+ result = await message('chat', { tabId, text: request, mode: 'act', requestId: 'owned-delete-after-correction', locale: 'en' });
+ } finally {
+ answering = false; await answerer;
+ }
const toolResults = (result.updates || []).filter(event => event.type === 'tool_result').map(event => ({ name: event.data?.name,
success: event.data?.result?.success, guard: event.data?.result?.actionGuard || null,
error: event.data?.result?.error ? String(event.data.result.error).slice(0, 400) : null }));