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
Drop a page-1 continuation only when it disagrees with the call's own read
Claudea5f7c42819a0
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex bf5ef4d5f..860c985b3 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -11322,11 +11322,12 @@ export class Agent extends LoopDetector {&& Object.keys(continuation).length > 0 && Object.keys(continuation).every(key => allowed.includes(key))&& !String(continuation.tree_revision ?? '').trim() && !String(next.tree_revision ?? '').trim()&& [undefined, null, '', 1, '1'].includes(continuation.page)- // Only a call that asks for a read of its own at the top level has a- // placeholder here. A continuationArgs that is all the call carries is- // the restart the tool returned (page 1 of an anchored subtree after- // its revision changed), and it is the read.- && allowed.some(key => key !== 'tree_revision' && String(next[key] ?? '').trim() !== '');+ // It is a placeholder only beside a read of the call's own that it+ // disagrees with. A restart nested alone, or beside top-level fields+ // that agree with it (a partial copy), is the restart the tool+ // returned (page 1 of an anchored subtree after its revision changed),+ // and it is the read.+ && Object.entries(continuation).some(([key, value]) => String(next[key] ?? '').trim() !== '' && !Object.is(next[key], value));if (restart) {delete next.continuationArgs;repaired = true;diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex d01c1869c..582d86c3c 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -11000,11 +11000,12 @@ export class Agent extends LoopDetector {&& Object.keys(continuation).length > 0 && Object.keys(continuation).every(key => allowed.includes(key))&& !String(continuation.tree_revision ?? '').trim() && !String(next.tree_revision ?? '').trim()&& [undefined, null, '', 1, '1'].includes(continuation.page)- // Only a call that asks for a read of its own at the top level has a- // placeholder here. A continuationArgs that is all the call carries is- // the restart the tool returned (page 1 of an anchored subtree after- // its revision changed), and it is the read.- && allowed.some(key => key !== 'tree_revision' && String(next[key] ?? '').trim() !== '');+ // It is a placeholder only beside a read of the call's own that it+ // disagrees with. A restart nested alone, or beside top-level fields+ // that agree with it (a partial copy), is the restart the tool+ // returned (page 1 of an anchored subtree after its revision changed),+ // and it is the read.+ && Object.entries(continuation).some(([key, value]) => String(next[key] ?? '').trim() !== '' && !Object.is(next[key], value));if (restart) {delete next.continuationArgs;repaired = true;diff --git a/test/read-continuation-schema.mjs b/test/read-continuation-schema.mjsindex 5579b722f..63d761930 100644--- a/test/read-continuation-schema.mjs+++ b/test/read-continuation-schema.mjs@@ -228,6 +228,11 @@ for (const browser of ['chrome', 'firefox']) {assert.equal(repaired.args.maxChars, 6000);const text = agent._repairToolCallArgs('get_accessibility_tree', { continuationArgs: JSON.stringify(restart) });assert.equal(text.args.ref_id, 'ref_12');+ // Beside top-level fields that only repeat part of it, it is still the read.+ const partial = agent._repairToolCallArgs('get_accessibility_tree', { maxChars: 6000, continuationArgs: restart });+ assert.equal(partial.result, undefined);+ assert.equal(partial.args.ref_id, 'ref_12');+ assert.equal(partial.args.filter, 'interactive');});test(`${browser}: oversized declared prose windows are bounded without losing the requested document position`, () => {