Skip to content

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

Offer the runtime's own Ask limitation directly instead of asking the classifier

Claude20b8f1ad3ec7
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 594c00c12..ef3d44ebc 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -27317,6 +27317,13 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
|| this.selectionGroundingScopes.has(tabId)) {
return;
}
+ // Nothing the user asked is unfulfilled here, so the classifier would
+ // rightly answer "none" for a read-only request: the runtime itself says
+ // a retry in Act is the recovery, and offers it directly.
+ if (runOptions?.autoModeRouting && runtimeLimitation) {
+ onUpdate('ask_mode_handoff', { value: 'act' });
+ return;
+ }
const handoffContext = this.systemOneContext(tabId);
try {
const provider = this._activeProvider(tabId);
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 15ff60c61..b7584e79b 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -24352,6 +24352,13 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
|| this.selectionGroundingScopes.has(tabId)) {
return;
}
+ // Nothing the user asked is unfulfilled here, so the classifier would
+ // rightly answer "none" for a read-only request: the runtime itself says
+ // a retry in Act is the recovery, and offers it directly.
+ if (runOptions?.autoModeRouting && runtimeLimitation) {
+ onUpdate('ask_mode_handoff', { value: 'act' });
+ return;
+ }
const handoffContext = this.systemOneContext(tabId);
try {
const provider = this._activeProvider(tabId);
diff --git a/test/auto-mode.mjs b/test/auto-mode.mjs
index 243886109..ec9339447 100644
--- a/test/auto-mode.mjs
+++ b/test/auto-mode.mjs
@@ -826,7 +826,10 @@ for (const build of BUILDS) {
const settle = () => new Promise(resolve => setImmediate(resolve));
const f = fixture(Agent, { replies: [done('Unused.')] });
delete f.agent._maybeEmitAskModeHandoff;
- f.agent._jevClassify = async () => 'act';
+ // A read-only request has no unfulfilled action, so a classifier asked
+ // about it answers none; the runtime's own limitation does not depend on it.
+ let classified = 0;
+ f.agent._jevClassify = async () => { classified += 1; return 'none'; };
f.agent.readCompletenessStates.set(f.tab, { required: true, complete: false, requiresExpansionEvidence: true, treeCoverageComplete: true });
const limitation = f.agent._readCompletenessLimitation(f.tab);
assert.match(limitation, /Ask mode cannot expand them/);
@@ -837,6 +840,7 @@ for (const build of BUILDS) {
await settle();
assert.deepEqual(f.updates.filter(update => update.type === 'ask_mode_handoff').map(update => update.data), [{ value: 'act' }],
'only the runtime limitation is offered the switch');
+ assert.equal(classified, 0, 'the runtime limitation is offered without asking the classifier');
});
test(`${build}: a slow decision model leaves the turn read-only after the grace period`, async () => {