Skip to content

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

Count an explicit empty ref_id as a disagreement with an anchored placeholder

Claude8ca1ba2015ee
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 1fb24f40c..05e48283f 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -11338,7 +11338,7 @@ export class Agent extends LoopDetector {
// (a restart nested alone, or beside fields that agree, is the read).
&& (String(continuation.ref_id ?? '').trim() === ''
? allowed.some(key => key !== 'tree_revision' && (key === 'ref_id' ? Object.hasOwn(next, key) : String(next[key] ?? '').trim() !== ''))
- : Object.entries(continuation).some(([key, value]) => String(next[key] ?? '').trim() !== '' && !agrees(key, value)));
+ : Object.entries(continuation).some(([key, value]) => (key === 'ref_id' ? Object.hasOwn(next, key) : String(next[key] ?? '').trim() !== '') && !agrees(key, value)));
if (restart) {
delete next.continuationArgs;
repaired = true;
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index f0f6aff54..202fa9d61 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -11016,7 +11016,7 @@ export class Agent extends LoopDetector {
// (a restart nested alone, or beside fields that agree, is the read).
&& (String(continuation.ref_id ?? '').trim() === ''
? allowed.some(key => key !== 'tree_revision' && (key === 'ref_id' ? Object.hasOwn(next, key) : String(next[key] ?? '').trim() !== ''))
- : Object.entries(continuation).some(([key, value]) => String(next[key] ?? '').trim() !== '' && !agrees(key, value)));
+ : Object.entries(continuation).some(([key, value]) => (key === 'ref_id' ? Object.hasOwn(next, key) : String(next[key] ?? '').trim() !== '') && !agrees(key, value)));
if (restart) {
delete next.continuationArgs;
repaired = true;
diff --git a/test/read-continuation-schema.mjs b/test/read-continuation-schema.mjs
index bbca6af3e..b3877eead 100644
--- a/test/read-continuation-schema.mjs
+++ b/test/read-continuation-schema.mjs
@@ -257,6 +257,10 @@ for (const browser of ['chrome', 'firefox']) {
const repaired = agent._repairToolCallArgs('get_accessibility_tree', { ref_id: '', continuationArgs: { filter: 'interactive', page: 1 } });
assert.equal(repaired.result, undefined);
assert.deepEqual(repaired.args, { ref_id: '' });
+ // An explicit document-root scope disagrees with an anchored page-1 object.
+ const anchored = agent._repairToolCallArgs('get_accessibility_tree', { ref_id: '', continuationArgs: { filter: 'interactive', ref_id: 'ref_12', page: 1 } });
+ assert.equal(anchored.result, undefined);
+ assert.deepEqual(anchored.args, { ref_id: '' });
});
test(`${browser}: an unanchored or loosely written page-1 object beside a read is a placeholder`, () => {