Skip to content

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

Lean vision runs keep the same-response done(success) check

Emre Sokullu2e76b13eac22
diff --git a/docs/lean-mode.md b/docs/lean-mode.md
index c58be8757..110947135 100644
--- a/docs/lean-mode.md
+++ b/docs/lean-mode.md
@@ -99,6 +99,8 @@ These quality guards keep running, each because a hard check depends on it (`LEA
| `action-no-progress-classification` | It feeds the loop detector, a budget. |
| `terminal-recovery-no-success` | It is the ending of the step-limit and observation budgets. |
+In a vision run (docs/vision-mode.md) lean mode also keeps `done-invariant-shape-checks` (`_guardSkipped`): the model sees what an action did only in the screen update after its batch, so `done(success)` in the same response as the action, a click on Send and done together, reports a result nobody has looked at. It is refused once with a note, as in a full run.
+
## What to expect
- **The model checks its own work.** WebBrain does not tell it that a write could not be read back or that the page still shows a form; the prompt asks it to read the page again before `done`. A strong model does this with a tree read or `inspect_viewport`; a weak one may report success too early, which is why Auto keeps lean mode off for local and small models.
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index f4a161a97..71dcde163 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -22852,7 +22852,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
* (no tab) is never skipped.
*/
_guardSkipped(id, tabId = null) {
- return this._leanRunActive(tabId) && leanSkipsGuard(id);
+ if (!this._leanRunActive(tabId) || !leanSkipsGuard(id)) return false;
+ // A vision run sees what an action did only in the screen update after
+ // its batch: done(success) in the same response as the action reports a
+ // result nobody has looked at, so lean mode keeps that check there.
+ if (id === 'done-invariant-shape-checks' && this._visionRunState?.(tabId)?.active === true) return false;
+ return true;
}
/**
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index df197b11a..a6ce0c3aa 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -19655,7 +19655,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
* (no tab) is never skipped.
*/
_guardSkipped(id, tabId = null) {
- return this._leanRunActive(tabId) && leanSkipsGuard(id);
+ if (!this._leanRunActive(tabId) || !leanSkipsGuard(id)) return false;
+ // A vision run sees what an action did only in the screen update after
+ // its batch: done(success) in the same response as the action reports a
+ // result nobody has looked at, so lean mode keeps that check there.
+ if (id === 'done-invariant-shape-checks' && this._visionRunState?.(tabId)?.active === true) return false;
+ return true;
}
/**
diff --git a/test/vision-mode-agent.mjs b/test/vision-mode-agent.mjs
index e1088cf76..e3dce500f 100644
--- a/test/vision-mode-agent.mjs
+++ b/test/vision-mode-agent.mjs
@@ -604,6 +604,27 @@ for (const build of (process.env.VISION_BUILDS || 'chrome,firefox').split(','))
assert.equal(redactionWarnings(report.updates).length, 1);
});
+ test(`${build}: in a lean vision run, done(success) in the same response as the action is refused once`, async () => {
+ const ctx = runAgent(step => {
+ if (step === 1) return { toolCalls: [call('click_at', { x: 300, y: 200 }), call('done', { summary: 'Sent.', outcome: 'success' })] };
+ if (step === 2) return { toolCalls: [call('done', { summary: 'Sent.', outcome: 'success' })] };
+ return { content: 'done' };
+ });
+ assert.equal(ctx.agent.leanMode, 'on');
+ await runLoop(ctx.agent, nextTab++, false);
+ assert.equal(ctx.requests.length, 2, 'the model decided again after the screen update');
+ assert.ok(toolTexts(ctx.requests[1]).some(text => /cannot rely on action or observation results from the same assistant tool batch/.test(text)), toolTexts(ctx.requests[1]).join('\n'));
+ assert.equal(ctx.dispatched.filter(entry => entry.name === 'done').length, 1);
+ // Only that check, and only on vision: lean mode on the tree path still skips it.
+ const agent = new Agent({});
+ agent._leanRunActive = () => true;
+ agent._visionRunState = () => ({ active: false });
+ assert.equal(agent._guardSkipped('done-invariant-shape-checks', 1), true);
+ agent._visionRunState = () => ({ active: true });
+ assert.equal(agent._guardSkipped('done-invariant-shape-checks', 1), false);
+ assert.equal(agent._guardSkipped('done-verification-debt', 1), true);
+ });
+
test(`${build}: a new run never shows or uses the previous run's frame when its first capture fails`, async () => {
const ctx = runAgent(step => {
if (step === 1) return { toolCalls: [call('done', { summary: 'Looked.', outcome: 'success' })] };