Skip to content

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

Trim a tree revision before comparing it, keeping its case

Claude634c4b5e325d
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 6156582e6..eac781b57 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -11317,6 +11317,8 @@ export class Agent extends LoopDetector {
const normalized = (value, key) => {
// A page is repaired below from up to four digits ("01" is 1).
if (key === 'page' && typeof value === 'string' && /^\s*\d{1,4}\s*$/.test(value)) return Number(value);
+ // The read trims a revision before comparing it; its case is kept.
+ if (key === 'tree_revision' && typeof value === 'string') return value.trim();
const scalar = decimal(value);
return typeof scalar === 'string' && key === 'filter' ? scalar.trim().toLowerCase() : scalar;
};
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index e55ba3461..cd690c8a8 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -10995,6 +10995,8 @@ export class Agent extends LoopDetector {
const normalized = (value, key) => {
// A page is repaired below from up to four digits ("01" is 1).
if (key === 'page' && typeof value === 'string' && /^\s*\d{1,4}\s*$/.test(value)) return Number(value);
+ // The read trims a revision before comparing it; its case is kept.
+ if (key === 'tree_revision' && typeof value === 'string') return value.trim();
const scalar = decimal(value);
return typeof scalar === 'string' && key === 'filter' ? scalar.trim().toLowerCase() : scalar;
};
diff --git a/test/read-continuation-schema.mjs b/test/read-continuation-schema.mjs
index 98fece8f9..2fc693b94 100644
--- a/test/read-continuation-schema.mjs
+++ b/test/read-continuation-schema.mjs
@@ -241,7 +241,7 @@ for (const browser of ['chrome', 'firefox']) {
}
});
- test(`${browser}: a tree revision is compared exactly, not case-folded`, () => {
+ test(`${browser}: a tree revision is trimmed but not case-folded`, () => {
const agent = new Agent({ getActive: () => null });
const page2 = { filter: 'interactive', maxDepth: 15, maxChars: 6000, ref_id: 'ref_12', page: 2, tree_revision: 'fnv1a64:d0891b5ff4884d4a' };
const altered = agent._repairToolCallArgs('get_accessibility_tree', { tree_revision: 'FNV1A64:D0891B5FF4884D4A', continuationArgs: page2 });
@@ -249,7 +249,7 @@ for (const browser of ['chrome', 'firefox']) {
const same = agent._repairToolCallArgs('get_accessibility_tree', { tree_revision: page2.tree_revision, continuationArgs: page2 });
assert.equal(same.result, undefined);
const padded = agent._repairToolCallArgs('get_accessibility_tree', { tree_revision: ` ${page2.tree_revision} `, continuationArgs: page2 });
- assert.equal(padded.result?.errorCode, 'invalid_tool_arguments', 'An opaque revision is not trimmed');
+ assert.equal(padded.result, undefined, 'The read trims a revision before comparing it');
});
test(`${browser}: an explicit empty ref_id beside an unanchored page-1 object is a top-level read`, () => {