Skip to content

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

fix(agent): scope completion freshness to shared evidence

Emre Sokullu290b8477d6a1
diff --git a/docs/providers-and-models.md b/docs/providers-and-models.md
index 59bef4d77..a3576c1ce 100644
--- a/docs/providers-and-models.md
+++ b/docs/providers-and-models.md
@@ -49,6 +49,10 @@ are unavailable or inconclusive. Confident pending/failed results require
recovery. Accepted fresh proof can establish generic publication evidence;
explicit recipient, payment, download, authorization and workflow contracts
remain required. Future votes and moderation outcomes are not certified.
+Freshness checks re-capture pixels or re-read the bounded AX observation used
+by the judge, with document/run identity checked separately. Text outside that
+observation does not invalidate an AX verdict; changed observed evidence does.
+Action history includes tool names without typed values or other arguments.
Rollout is additive: deploy Cloud `/v1/decisions` before releasing the extension.
An older Cloud deployment falls through to the active LLM and existing checks.
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 8c0047551..bc4651a7c 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -1,7 +1,7 @@
import { verifyBrowserCompletion } from './completion-runtime.js';
import { DECISION_SETTINGS_KEYS, resolveDecisionConfig } from './decision-config.js';
import { completionStopError } from './completion-verifier.js';
-import { COMPLETION_DOCUMENT_STAMP_SCRIPT } from './completion-document.js';
+import { COMPLETION_DOCUMENT_STAMP_SCRIPT, COMPLETION_DOCUMENT_IDENTITY_SCRIPT } from './completion-document.js';
import { JEV_FAST_KEYS, JEV_CLASSIFIER_THRESHOLD, JEV_BROWSER_THRESHOLD, confidentChoice, buildJevBrowserRequest, decideJevBrowser, jevVisualInputRequiresMainModel, JevFastSession } from './systemone-fast.js';
import { redactSystemOneText, wrapSystemOneData, boundedSystemOneText } from './systemone-evidence.js';
import { createSystemOneJudge, isSystemOneResponseContractError, systemOneFailureReason, SYSTEM_ONE_COST_PROVIDER } from './systemone-judge.js';
@@ -7190,8 +7190,8 @@ export class Agent extends LoopDetector {
return { status: reason, reason, ...(code ? { code } : {}), ...detail };
}
- async _completionDocumentStamp(tabId) {
- const result = await cdpClient.evaluate(tabId, COMPLETION_DOCUMENT_STAMP_SCRIPT);
+ async _completionDocumentStamp(tabId, documentOnly = false) {
+ const result = await cdpClient.evaluate(tabId, documentOnly ? COMPLETION_DOCUMENT_IDENTITY_SCRIPT : COMPLETION_DOCUMENT_STAMP_SCRIPT);
return result?.result?.value || '';
}
diff --git a/src/chrome/src/agent/completion-document.js b/src/chrome/src/agent/completion-document.js
index a55926af9..a1b59551e 100644
--- a/src/chrome/src/agent/completion-document.js
+++ b/src/chrome/src/agent/completion-document.js
@@ -18,3 +18,6 @@ export function completionDocumentStamp() {
}
export const COMPLETION_DOCUMENT_STAMP_SCRIPT = `(${completionDocumentStamp.toString()})()`;
+// Document identity is separate from evidence freshness: unrelated page text
+// must not invalidate an observation that did not include it.
+export const COMPLETION_DOCUMENT_IDENTITY_SCRIPT = '[location.href, performance.timeOrigin].join("|")';
diff --git a/src/chrome/src/agent/completion-runtime.js b/src/chrome/src/agent/completion-runtime.js
index af4e598dd..1226d8a23 100644
--- a/src/chrome/src/agent/completion-runtime.js
+++ b/src/chrome/src/agent/completion-runtime.js
@@ -41,10 +41,15 @@ async function evaluateBrowserCompletion(agent, tabId, { pageState = {}, pageUrl
&& scope === JSON.stringify([agent.completionInvariants.get(tabId)?.runToken, agent.completionInvariants.get(tabId)?.lastAction?.sequence, agent._progressTaskKeyHash(tabId), config.provider, config.model, config.url, provider.model, provider.supportsVision, JSON.stringify(config)]);
const currentIdentity = async evidence => !!evidence.identity && currentRun()
&& JSON.stringify(resolveDecisionConfig(await chrome.storage.local.get(DECISION_SETTINGS_KEYS), compass)) === JSON.stringify(config)
- && evidence.identity === await agent._completionDocumentStamp(tabId) && currentRun();
+ && evidence.identity === await agent._completionDocumentStamp(tabId, true) && currentRun();
const current = async evidence => {
if (!await currentIdentity(evidence)) return false;
- if (evidence.modality !== 'vision') return true;
+ if (evidence.modality !== 'vision') {
+ // Re-read the bounded AX evidence actually sent to the judge. Full-body
+ // clocks/feeds outside that evidence do not establish staleness.
+ const fresh = await capture('ax', true);
+ return fresh?.key === (evidence.key || evidence.evidenceKey) && await currentIdentity(evidence);
+ }
// Text and input stamps cannot detect canvas, image or CSS changes. Take a
// new redacted, budgeted capture after the request; never reuse that cache.
let fresh;
@@ -61,16 +66,18 @@ async function evaluateBrowserCompletion(agent, tabId, { pageState = {}, pageUrl
const reads = messages.filter(m => m.role === 'tool' && /read_page|get_accessibility_tree|verify_form/.test(toolNames.get(m.tool_call_id) || m.name || ''));
const selectedReads = [...new Set([...reads.filter(m => /rules|guidelines|moderation/i.test(String(m.content))).slice(-2), ...reads.slice(-2)])];
const history = selectedReads.map(m => ({ tool: toolNames.get(m.tool_call_id) || m.name, evidence: wrapSystemOneData(boundedText(redactSystemOneText(String(m.content)), 450)) }));
- const recordedActions = messages.flatMap(m => m.tool_calls || []).filter(c => /^(type|fill|click|navigate|set_)/.test(c.function?.name || '')).slice(-8).map(c => ({ tool: c.function.name, args: wrapSystemOneData(boundedText(redactSystemOneText(String(c.function.arguments || '')), 180)) }));
+ // Entered values can be secrets without recognizable labels. Action names
+ // supply history without sending arbitrary tool arguments to another judge.
+ const recordedActions = messages.flatMap(m => m.tool_calls || []).filter(c => /^(type|fill|click|navigate|set_)/.test(c.function?.name || '')).slice(-8).map(c => ({ tool: c.function.name }));
const captures = new Map();
const capture = async (modality, refresh = false) => {
- const before = await agent._completionDocumentStamp(tabId);
+ const before = await agent._completionDocumentStamp(tabId, true);
const cached = captures.get(modality);
const reusable = cached?.identity === before && context.isCurrent();
+ if (!refresh && reusable) return cached;
// A new vision judgment needs both its evidence and its post-request
// freshness capture. With only one slot left, use AX before paying a judge.
if (modality === 'vision' && agent._canTakeAutoScreenshot?.(tabId, refresh || reusable ? 1 : 2) === false) return null;
- if (!refresh && reusable) return cached;
let observation;
if (modality === 'vision') {
let pixels = await agent._captureCompletionJudgeImage(tabId);
@@ -83,7 +90,7 @@ async function evaluateBrowserCompletion(agent, tabId, { pageState = {}, pageUrl
if (result?.success === false || !result?.pageContent) return null;
observation = { observation: wrapSystemOneData(boundedText(redactSystemOneText(result.pageContent), 4500)) };
}
- const identity = await agent._completionDocumentStamp(tabId);
+ const identity = await agent._completionDocumentStamp(tabId, true);
if (!identity || identity !== before || !context.isCurrent()) return null;
const submit = agent._completionSubmitStates.get(tabId);
const info = {
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index f1ae234f6..ceee65a0d 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -1,7 +1,7 @@
import { verifyBrowserCompletion } from './completion-runtime.js';
import { DECISION_SETTINGS_KEYS, resolveDecisionConfig } from './decision-config.js';
import { completionStopError } from './completion-verifier.js';
-import { COMPLETION_DOCUMENT_STAMP_SCRIPT } from './completion-document.js';
+import { COMPLETION_DOCUMENT_STAMP_SCRIPT, COMPLETION_DOCUMENT_IDENTITY_SCRIPT } from './completion-document.js';
import { JEV_FAST_KEYS, JEV_CLASSIFIER_THRESHOLD, JEV_BROWSER_THRESHOLD, confidentChoice, buildJevBrowserRequest, decideJevBrowser, jevVisualInputRequiresMainModel, JevFastSession } from './systemone-fast.js';
import { redactSystemOneText, wrapSystemOneData, boundedSystemOneText } from './systemone-evidence.js';
import { createSystemOneJudge, isSystemOneResponseContractError, systemOneFailureReason, SYSTEM_ONE_COST_PROVIDER } from './systemone-judge.js';
@@ -7041,8 +7041,8 @@ export class Agent extends LoopDetector {
return { status: reason, reason, ...(code ? { code } : {}), ...detail };
}
- async _completionDocumentStamp(tabId) {
- const result = await browser.tabs.executeScript(tabId, { code: COMPLETION_DOCUMENT_STAMP_SCRIPT });
+ async _completionDocumentStamp(tabId, documentOnly = false) {
+ const result = await browser.tabs.executeScript(tabId, { code: documentOnly ? COMPLETION_DOCUMENT_IDENTITY_SCRIPT : COMPLETION_DOCUMENT_STAMP_SCRIPT });
return result?.[0] || '';
}
diff --git a/src/firefox/src/agent/completion-document.js b/src/firefox/src/agent/completion-document.js
index a55926af9..a1b59551e 100644
--- a/src/firefox/src/agent/completion-document.js
+++ b/src/firefox/src/agent/completion-document.js
@@ -18,3 +18,6 @@ export function completionDocumentStamp() {
}
export const COMPLETION_DOCUMENT_STAMP_SCRIPT = `(${completionDocumentStamp.toString()})()`;
+// Document identity is separate from evidence freshness: unrelated page text
+// must not invalidate an observation that did not include it.
+export const COMPLETION_DOCUMENT_IDENTITY_SCRIPT = '[location.href, performance.timeOrigin].join("|")';
diff --git a/src/firefox/src/agent/completion-runtime.js b/src/firefox/src/agent/completion-runtime.js
index 87e5c6071..a343a06b4 100644
--- a/src/firefox/src/agent/completion-runtime.js
+++ b/src/firefox/src/agent/completion-runtime.js
@@ -41,10 +41,15 @@ async function evaluateBrowserCompletion(agent, tabId, { pageState = {}, pageUrl
&& scope === JSON.stringify([agent.completionInvariants.get(tabId)?.runToken, agent.completionInvariants.get(tabId)?.lastAction?.sequence, agent._progressTaskKeyHash(tabId), config.provider, config.model, config.url, provider.model, provider.supportsVision, JSON.stringify(config)]);
const currentIdentity = async evidence => !!evidence.identity && currentRun()
&& JSON.stringify(resolveDecisionConfig(await browser.storage.local.get(DECISION_SETTINGS_KEYS), compass)) === JSON.stringify(config)
- && evidence.identity === await agent._completionDocumentStamp(tabId) && currentRun();
+ && evidence.identity === await agent._completionDocumentStamp(tabId, true) && currentRun();
const current = async evidence => {
if (!await currentIdentity(evidence)) return false;
- if (evidence.modality !== 'vision') return true;
+ if (evidence.modality !== 'vision') {
+ // Re-read the bounded AX evidence actually sent to the judge. Full-body
+ // clocks/feeds outside that evidence do not establish staleness.
+ const fresh = await capture('ax', true);
+ return fresh?.key === (evidence.key || evidence.evidenceKey) && await currentIdentity(evidence);
+ }
// Text and input stamps cannot detect canvas, image or CSS changes. Take a
// new redacted, budgeted capture after the request; never reuse that cache.
let fresh;
@@ -61,16 +66,18 @@ async function evaluateBrowserCompletion(agent, tabId, { pageState = {}, pageUrl
const reads = messages.filter(m => m.role === 'tool' && /read_page|get_accessibility_tree|verify_form/.test(toolNames.get(m.tool_call_id) || m.name || ''));
const selectedReads = [...new Set([...reads.filter(m => /rules|guidelines|moderation/i.test(String(m.content))).slice(-2), ...reads.slice(-2)])];
const history = selectedReads.map(m => ({ tool: toolNames.get(m.tool_call_id) || m.name, evidence: wrapSystemOneData(boundedText(redactSystemOneText(String(m.content)), 450)) }));
- const recordedActions = messages.flatMap(m => m.tool_calls || []).filter(c => /^(type|fill|click|navigate|set_)/.test(c.function?.name || '')).slice(-8).map(c => ({ tool: c.function.name, args: wrapSystemOneData(boundedText(redactSystemOneText(String(c.function.arguments || '')), 180)) }));
+ // Entered values can be secrets without recognizable labels. Action names
+ // supply history without sending arbitrary tool arguments to another judge.
+ const recordedActions = messages.flatMap(m => m.tool_calls || []).filter(c => /^(type|fill|click|navigate|set_)/.test(c.function?.name || '')).slice(-8).map(c => ({ tool: c.function.name }));
const captures = new Map();
const capture = async (modality, refresh = false) => {
- const before = await agent._completionDocumentStamp(tabId);
+ const before = await agent._completionDocumentStamp(tabId, true);
const cached = captures.get(modality);
const reusable = cached?.identity === before && context.isCurrent();
+ if (!refresh && reusable) return cached;
// A new vision judgment needs both its evidence and its post-request
// freshness capture. With only one slot left, use AX before paying a judge.
if (modality === 'vision' && agent._canTakeAutoScreenshot?.(tabId, refresh || reusable ? 1 : 2) === false) return null;
- if (!refresh && reusable) return cached;
let observation;
if (modality === 'vision') {
let pixels = await agent._captureCompletionJudgeImage(tabId);
@@ -83,7 +90,7 @@ async function evaluateBrowserCompletion(agent, tabId, { pageState = {}, pageUrl
if (result?.success === false || !result?.pageContent) return null;
observation = { observation: wrapSystemOneData(boundedText(redactSystemOneText(result.pageContent), 4500)) };
}
- const identity = await agent._completionDocumentStamp(tabId);
+ const identity = await agent._completionDocumentStamp(tabId, true);
if (!identity || identity !== before || !context.isCurrent()) return null;
const submit = agent._completionSubmitStates.get(tabId);
const info = {
diff --git a/test/completion-document.mjs b/test/completion-document.mjs
index 77577c7a5..a9bac2b3e 100644
--- a/test/completion-document.mjs
+++ b/test/completion-document.mjs
@@ -1,9 +1,11 @@
import assert from 'node:assert/strict';
import { test } from 'node:test';
+import { readFile } from 'node:fs/promises';
import { chromium, firefox } from 'playwright';
for (const [build, browserType] of [['chrome', chromium], ['firefox', firefox]]) {
- const { COMPLETION_DOCUMENT_STAMP_SCRIPT } = await import(`../src/${build}/src/agent/completion-document.js`);
+ const { COMPLETION_DOCUMENT_STAMP_SCRIPT, COMPLETION_DOCUMENT_IDENTITY_SCRIPT } = await import(`../src/${build}/src/agent/completion-document.js`);
+ const treeSource = await readFile(new URL(`../src/${build}/src/content/accessibility-tree.js`, import.meta.url), 'utf8');
const { verifyBrowserCompletion } = await import(`../src/${build}/src/agent/completion-runtime.js`);
const { probeDecisionVision } = await import(`../src/${build}/src/agent/decision-vision-probe.js`);
test(`${build}: completion stamp detects accessibility-only changes and rejects reverted checkbox success`, async () => {
@@ -11,8 +13,9 @@ for (const [build, browserType] of [['chrome', chromium], ['firefox', firefox]])
const previousChrome = globalThis.chrome, previousBrowser = globalThis.browser;
try {
const page = await browser.newPage();
+ await page.addScriptTag({ content: treeSource });
await page.setContent('<input id="check" type="checkbox" checked><input id="text" value="unchanged"><button id="button">Save</button><div id="state" role="status">Published</div>');
- const stamp = () => page.evaluate(COMPLETION_DOCUMENT_STAMP_SCRIPT);
+ const stamp = (_tab, documentOnly = false) => page.evaluate(documentOnly ? COMPLETION_DOCUMENT_IDENTITY_SCRIPT : COMPLETION_DOCUMENT_STAMP_SCRIPT);
const initial = await stamp();
for (const [selector, property] of [['#check', 'checked'], ['#check', 'indeterminate'], ['#text', 'disabled'], ['#text', 'readOnly']]) {
await page.locator(selector).evaluate((element, property) => { element[property] = !element[property]; }, property);
@@ -33,7 +36,7 @@ for (const [build, browserType] of [['chrome', chromium], ['firefox', firefox]])
_latestTaskText: () => 'Check this checkbox', _originalTaskText: () => '', _progressTaskKeyHash: () => 'check',
_planExecutionGuards: new Map(), completionInvariants: new Map([[1, { runToken: 'run' }]]),
_completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(), _completionDocumentStamp: stamp,
- executeTool: async () => ({ success: true, pageContent: 'Checkbox checked' }), recordSystemOneVerdict() {},
+ executeTool: async () => ({ success: true, ...await page.evaluate(() => window.__generateAccessibilityTree('all', 15, 5500)) }), recordSystemOneVerdict() {},
evaluateSystemOne: async () => {
await page.locator('#check').evaluate(element => { element.checked = false; });
return { model: 'kev-latest', answers: { task_outcome: { choice: 'succeeded', probabilities: { succeeded: .99 } } } };
@@ -53,10 +56,11 @@ for (const [build, browserType] of [['chrome', chromium], ['firefox', firefox]])
const previousChrome = globalThis.chrome, previousBrowser = globalThis.browser;
try {
const page = await browser.newPage();
- const stamp = () => page.evaluate(COMPLETION_DOCUMENT_STAMP_SCRIPT);
+ await page.addScriptTag({ content: treeSource });
+ const stamp = (_tab, documentOnly = false) => page.evaluate(documentOnly ? COMPLETION_DOCUMENT_IDENTITY_SCRIPT : COMPLETION_DOCUMENT_STAMP_SCRIPT);
globalThis.chrome = globalThis.browser = { storage: { local: { get: async () => ({ decisionProvider: 'local', systemOneEnabled: true }) } } };
for (const attribute of [null, 'aria-label']) {
- await page.setContent('<div id="state" role="status">Published</div>');
+ await page.setContent('<h1 id="state">Published</h1>');
const replace = value => page.locator('#state').evaluate((element, { attribute, value }) => {
if (attribute) element.setAttribute(attribute, value); else element.textContent = value;
}, { attribute, value });
@@ -72,7 +76,7 @@ for (const [build, browserType] of [['chrome', chromium], ['firefox', firefox]])
_latestTaskText: () => 'Verify the requested emoji', _originalTaskText: () => '', _progressTaskKeyHash: () => 'emoji',
_planExecutionGuards: new Map(), completionInvariants: new Map([[1, { runToken: 'run' }]]),
_completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(), _completionDocumentStamp: stamp,
- executeTool: async () => ({ success: true, pageContent: 'Requested emoji: πŸ˜€' }), recordSystemOneVerdict() {},
+ executeTool: async () => ({ success: true, ...await page.evaluate(() => window.__generateAccessibilityTree('all', 15, 5500)) }), recordSystemOneVerdict() {},
evaluateSystemOne: async () => {
await replace('😁');
return { model: 'kev-latest', answers: { task_outcome: { choice: 'succeeded', probabilities: { succeeded: .99 } } } };
@@ -88,6 +92,43 @@ for (const [build, browserType] of [['chrome', chromium], ['firefox', firefox]])
await browser.close();
}
});
+ test(`${build}: AX freshness ignores live text outside the judge observation but rejects changed observed results`, async () => {
+ const browser = await browserType.launch();
+ const previousChrome = globalThis.chrome, previousBrowser = globalThis.browser;
+ try {
+ const page = await browser.newPage();
+ await page.addScriptTag({ content: treeSource });
+ await page.setContent('<h1 id="result">Requested post published</h1>' + Array.from({ length: 120 }, (_, i) => `<p>Archive item ${i}: ${'stable details '.repeat(5)}</p>`).join('') + '<div id="clock" role="timer">CLOCK_INITIAL</div>');
+ const fullStamp = await page.evaluate(COMPLETION_DOCUMENT_STAMP_SCRIPT);
+ globalThis.chrome = globalThis.browser = { storage: { local: { get: async () => ({ decisionProvider: 'local', systemOneEnabled: true }) } } };
+ let changeResult = false, requests = 0, reads = 0;
+ const provider = { model: 'active', supportsVision: false, config: { category: 'local' } };
+ const agent = {
+ _activeProvider: () => provider, _runAbortSignal: () => null, systemOneContext: () => ({ isCurrent: () => true }),
+ _latestTaskText: () => 'Verify the requested post was published', _originalTaskText: () => '', _progressTaskKeyHash: () => 'post',
+ _planExecutionGuards: new Map(), completionInvariants: new Map([[1, { runToken: 'run' }]]),
+ _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(),
+ _completionDocumentStamp: (_tab, documentOnly) => page.evaluate(documentOnly ? COMPLETION_DOCUMENT_IDENTITY_SCRIPT : COMPLETION_DOCUMENT_STAMP_SCRIPT),
+ executeTool: async () => { reads++; return { success: true, ...await page.evaluate(() => window.__generateAccessibilityTree('all', 15, 5500)) }; }, recordSystemOneVerdict() {},
+ evaluateSystemOne: async (_tab, _client, args) => {
+ requests++;
+ assert.doesNotMatch(args.state[1].observation, /CLOCK_/);
+ await page.locator('#clock').evaluate((element, value) => { element.textContent = value; }, `CLOCK_UPDATED_${requests}`);
+ if (changeResult) await page.locator('#result').evaluate(element => { element.textContent = 'Requested post is an unsubmitted draft'; });
+ return { model: 'kev-latest', answers: { task_outcome: { choice: 'succeeded', probabilities: { succeeded: .99 } } } };
+ },
+ };
+ assert.equal((await verifyBrowserCompletion(agent, 1)).outcome, 'succeeded');
+ assert.notEqual(await page.evaluate(COMPLETION_DOCUMENT_STAMP_SCRIPT), fullStamp, 'the old full-body fingerprint would reject the clock update');
+ assert.equal(requests, 1); assert.equal(reads, 2);
+ agent._completionVerdicts.clear(); changeResult = true;
+ const changed = await verifyBrowserCompletion(agent, 1);
+ assert.equal(changed.outcome, 'pending'); assert.equal(changed.engine, 'freshness');
+ } finally {
+ globalThis.chrome = previousChrome; globalThis.browser = previousBrowser;
+ await browser.close();
+ }
+ });
test(`${build}: vision capability probe uses two distinct pixel facts and rejects constant answers`, async () => {
const browser = await browserType.launch();
try {
diff --git a/test/completion-verifier.mjs b/test/completion-verifier.mjs
index 4dd5c1984..98b0daef5 100644
--- a/test/completion-verifier.mjs
+++ b/test/completion-verifier.mjs
@@ -135,6 +135,7 @@ for (const build of ['chrome', 'firefox']) {
conversationIds: new Map([[1, 'session']]), conversations: new Map([[1, [
{ role: 'assistant', tool_calls: [{ id: 'rules', function: { name: 'read_page', arguments: '{}' } }] },
{ role: 'tool', tool_call_id: 'rules', content: '{"text":"Community rules: relevant tools are allowed"}' },
+ { role: 'assistant', tool_calls: ['type_ax', 'type_text', 'set_field', 'fill_form', 'navigate'].map((name, index) => ({ id: `action-${index}`, function: { name, arguments: JSON.stringify({ ref_id: 'observed-ref', text: 'unlabelled-entered-value', value: 'nested-entered-value', fields: [{ text: 'another-entered-value' }], url: 'https://example.test/?data=opaque-entered-value' }) } })) },
]]]),
_completionDocumentStamp: async () => stamp, _captureCompletionJudgeImage: async () => pixels,
_budgetForCapture: () => ({ maxTargetPx: 1568, maxTargetTokens: 1568 }), _shrinkImageForBudget: async dataUrl => ({ dataUrl }),
@@ -147,6 +148,8 @@ for (const build of ['chrome', 'firefox']) {
assert.equal(verdict.engine, 'compass'); assert.equal(verdict.modality, 'vision'); assert.equal(lastRequest.config.model, config.DEFAULT_DECISION_MODEL);
assert.equal(lastRequest.headers['X-WebBrain-Help-Improve'], '0'); assert.equal(lastRequest.metadata.session_id, 'session');
assert.match(JSON.stringify(lastRequest.state), /Community rules/);
+ assert.doesNotMatch(JSON.stringify(lastRequest.state), /entered-value/);
+ assert.deepEqual(lastRequest.state[0].recorded_actions, ['type_ax', 'type_text', 'set_field', 'fill_form', 'navigate'].map(tool => ({ tool })));
const initialState = JSON.stringify(lastRequest.state);
await runtime.verifyBrowserCompletion(agent, 1, { pageUrl: 'https://old.reddit.com/comments/new' });
assert.equal(JSON.stringify(lastRequest.state), initialState);
@@ -270,7 +273,7 @@ for (const build of ['chrome', 'firefox']) {
const engine = stored.systemOneEnabled === true && stored.systemOneDoneEnabled !== false ? 'decision' : 'llm';
assert.equal(verdict.outcome, 'succeeded'); assert.equal(verdict.modality, 'ax');
assert.deepEqual(calls, [`${engine}:vision`, `${engine}:ax`]);
- assert.equal(reads, 1); assert.equal(captures, 2);
+ assert.equal(reads, 2, 'AX evidence must be re-read after its judgment'); assert.equal(captures, 2);
}
} finally {
globalThis.chrome = previousChrome; globalThis.browser = previousBrowser;
@@ -282,7 +285,7 @@ for (const build of ['chrome', 'firefox']) {
const navigatorDescriptor = Object.getOwnPropertyDescriptor(globalThis, 'navigator');
Object.defineProperty(globalThis, 'navigator', { configurable: true, value: { onLine: true } });
try {
- for (const engine of ['decision', 'llm']) for (const [cap, used, modality] of [[0, 10, 'vision'], [1, 0, 'ax'], [2, 0, 'vision'], [3, 2, 'ax'], [3, 1, 'vision'], [2, 2, 'ax']]) {
+ for (const engine of ['decision', 'llm']) for (const [cap, used, modality] of [[0, 10, 'vision'], [1, 0, 'ax'], [2, 0, 'vision'], [3, 0, 'vision'], [3, 2, 'ax'], [3, 1, 'vision'], [2, 2, 'ax']]) {
globalThis.chrome = globalThis.browser = { storage: { local: { get: async () => ({ decisionProvider: 'local', systemOneEnabled: engine === 'decision', decisionVisionMode: 'on' }) } } };
let captures = 0, spent = used, requests = 0;
const active = { model: 'local-model', supportsVision: true, config: { category: 'local' }, chat() {} };
@@ -305,6 +308,12 @@ for (const build of ['chrome', 'firefox']) {
assert.equal(verdict.modality, modality);
assert.equal(captures, modality === 'vision' ? 2 : 0);
assert.equal(requests, 1);
+ if (cap === 3 && used === 0) {
+ const repeated = await runtime.verifyBrowserCompletion(agent, 1);
+ assert.equal(repeated.outcome, 'succeeded'); assert.equal(repeated.modality, 'vision');
+ assert.equal(requests, 1, 'a revalidated cached verdict needs no additional judge request');
+ assert.equal(captures, 3, 'the matching freshness capture must be reused after the last slot is spent');
+ }
if (cap) assert.ok(spent <= cap, 'freshness must honor the user screenshot cap');
}
} finally {