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
Treat a page-1 continuation as a placeholder only beside top-level read fields
Claude6477fb29ee99
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex dbfcdda3d..bf5ef4d5f 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -11321,7 +11321,12 @@ export class Agent extends LoopDetector {const restart = continuation && typeof continuation === 'object' && !Array.isArray(continuation)&& 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);+ && [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() !== '');if (restart) {delete next.continuationArgs;repaired = true;diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex 303e15223..d01c1869c 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -10999,7 +10999,12 @@ export class Agent extends LoopDetector {const restart = continuation && typeof continuation === 'object' && !Array.isArray(continuation)&& 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);+ && [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() !== '');if (restart) {delete next.continuationArgs;repaired = true;diff --git a/test/read-continuation-schema.mjs b/test/read-continuation-schema.mjsindex ee116021e..5579b722f 100644--- a/test/read-continuation-schema.mjs+++ b/test/read-continuation-schema.mjs@@ -216,6 +216,20 @@ for (const browser of ['chrome', 'firefox']) {}});+ test(`${browser}: a returned page-1 restart nested alone is still the read`, () => {+ // An anchored page-2 read whose revision changed returns a restart for page 1+ // with the original scope and no revision; nested alone it is the whole call.+ const agent = new Agent({ getActive: () => null });+ const restart = { filter: 'interactive', maxDepth: 15, maxChars: 6000, ref_id: 'ref_12', page: 1 };+ const repaired = agent._repairToolCallArgs('get_accessibility_tree', { continuationArgs: restart });+ assert.equal(repaired.result, undefined);+ assert.equal(repaired.args.ref_id, 'ref_12', 'The anchored subtree is kept');+ assert.equal(repaired.args.filter, 'interactive');+ 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');+ });+test(`${browser}: oversized declared prose windows are bounded without losing the requested document position`, () => {const agent = new Agent({ getActive: () => null });const schema = getToolsForMode('act', { tier: 'full' })