Skip to content

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

fix: stop Jev after malformed classifier responses

release-verification7c7f5b9e3185
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index d35ec671f..2ef8becb9 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -6800,7 +6800,7 @@ export class Agent extends LoopDetector {
const context = this.systemOneContext(tabId);
try {
const settings = await this._jevSettings();
- if (!settings?.systemOneFastClassifications || this._checkAbort(tabId) || !context.isCurrent()) return null;
+ if (!settings?.systemOneFastClassifications || this._jevSessions?.get(tabId)?.hardStopped || this._checkAbort(tabId) || !context.isCurrent()) return null;
// Classification receives plain text only; multimodal requests stay with the active provider.
if (!state || Object.values(state).some(value => value != null && typeof value !== 'string')) return null;
const text = JSON.stringify(state);
@@ -6815,6 +6815,12 @@ export class Agent extends LoopDetector {
this.recordSystemOneVerdict(tabId, { decision: choice ? 'classification' : 'fallback', reason: choice ? 'confident' : 'low_confidence', model: verdict.model }, context);
return this._checkAbort(tabId) || !context.isCurrent() ? null : choice;
} catch (error) {
+ if (isSystemOneResponseContractError(error)) {
+ this._jevSessions ??= new Map();
+ let session = this._jevSessions.get(tabId);
+ if (!session) { session = new JevFastSession(); this._jevSessions.set(tabId, session); }
+ session.hardStop();
+ }
this.recordSystemOneVerdict(tabId, { decision: 'fallback', reason: `classification_${this._isCostAllowanceError(error) ? 'cost_limit' : systemOneFailureReason(error)}` }, context);
return null;
}
diff --git a/src/chrome/src/agent/systemone-fast.js b/src/chrome/src/agent/systemone-fast.js
index 14b855605..2c26131ea 100644
--- a/src/chrome/src/agent/systemone-fast.js
+++ b/src/chrome/src/agent/systemone-fast.js
@@ -163,10 +163,11 @@ export class JevFastSession {
this.fallbackCount = 0;
this.fallbackContext = null;
this.completionCandidate = false;
+ this.hardStopped = false;
}
get fallbackBlocked() { return this.fallbackCount >= 2; }
recordFallback() { this.fallbackCount++; this.queue = []; }
- hardStop() { this.disabled = true; this.queue = []; }
+ hardStop() { this.hardStopped = true; this.disabled = true; this.queue = []; }
observe(snapshot) {
const context = JSON.stringify([snapshot?.documentToken, snapshot?.pageUrl, snapshot?.structure, snapshot?.progress, snapshot?.hasSensitiveControls === true]);
if (context !== this.fallbackContext) {
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 3c7e28f68..e60544cc2 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -6584,7 +6584,7 @@ export class Agent extends LoopDetector {
const context = this.systemOneContext(tabId);
try {
const settings = await this._jevSettings();
- if (!settings?.systemOneFastClassifications || this._checkAbort(tabId) || !context.isCurrent()) return null;
+ if (!settings?.systemOneFastClassifications || this._jevSessions?.get(tabId)?.hardStopped || this._checkAbort(tabId) || !context.isCurrent()) return null;
// Classification receives plain text only; multimodal requests stay with the active provider.
if (!state || Object.values(state).some(value => value != null && typeof value !== 'string')) return null;
const text = JSON.stringify(state);
@@ -6599,6 +6599,12 @@ export class Agent extends LoopDetector {
this.recordSystemOneVerdict(tabId, { decision: choice ? 'classification' : 'fallback', reason: choice ? 'confident' : 'low_confidence', model: verdict.model }, context);
return this._checkAbort(tabId) || !context.isCurrent() ? null : choice;
} catch (error) {
+ if (isSystemOneResponseContractError(error)) {
+ this._jevSessions ??= new Map();
+ let session = this._jevSessions.get(tabId);
+ if (!session) { session = new JevFastSession(); this._jevSessions.set(tabId, session); }
+ session.hardStop();
+ }
this.recordSystemOneVerdict(tabId, { decision: 'fallback', reason: `classification_${this._isCostAllowanceError(error) ? 'cost_limit' : systemOneFailureReason(error)}` }, context);
return null;
}
diff --git a/src/firefox/src/agent/systemone-fast.js b/src/firefox/src/agent/systemone-fast.js
index 14b855605..2c26131ea 100644
--- a/src/firefox/src/agent/systemone-fast.js
+++ b/src/firefox/src/agent/systemone-fast.js
@@ -163,10 +163,11 @@ export class JevFastSession {
this.fallbackCount = 0;
this.fallbackContext = null;
this.completionCandidate = false;
+ this.hardStopped = false;
}
get fallbackBlocked() { return this.fallbackCount >= 2; }
recordFallback() { this.fallbackCount++; this.queue = []; }
- hardStop() { this.disabled = true; this.queue = []; }
+ hardStop() { this.hardStopped = true; this.disabled = true; this.queue = []; }
observe(snapshot) {
const context = JSON.stringify([snapshot?.documentToken, snapshot?.pageUrl, snapshot?.structure, snapshot?.progress, snapshot?.hasSensitiveControls === true]);
if (context !== this.fallbackContext) {
diff --git a/test/systemone-fast.mjs b/test/systemone-fast.mjs
index e1e73a1de..d8d30d886 100644
--- a/test/systemone-fast.mjs
+++ b/test/systemone-fast.mjs
@@ -225,6 +225,24 @@ for (const build of ['chrome', 'firefox']) {
assert.equal(calls, 1);
});
+ test(`${build}: malformed classifier response hard-stops all Jev requests for the run`, async () => {
+ const provider = { name: 'test', model: 'active-model' }; const agent = new Agent({ getActive: () => provider });
+ Object.assign(storage, { systemOneEnabled: true, systemOneFastBrowser: true, systemOneFastClassifications: true, typesafeApiKey: 'synthetic' });
+ let calls = 0;
+ agent.evaluateSystemOne = async () => {
+ calls++;
+ const error = new Error('Invalid Jev distribution.');
+ error.code = 'JEV_INVALID_DISTRIBUTION';
+ throw error;
+ };
+ const classify = () => agent._jevClassify(1, 'classify', { yes: 'yes', no: 'no' }, { task: 'Classify this request.' });
+ assert.equal(await classify(), null);
+ assert.equal(agent._jevSessions.get(1).hardStopped, true);
+ assert.equal(await classify(), null);
+ assert.equal(await agent._maybeJevFastTurn(1, 'Click Save', [], 'act', new Set(['get_accessibility_tree', 'click_ax']), provider, {}), null);
+ assert.equal(calls, 1);
+ });
+
test(`${build}: click-only decisions and uncertain fill targets never invoke value preparation`, async () => {
const provider = { name: 'test', model: 'active-model' }; const agent = new Agent({ getActive: () => provider });
Object.assign(storage, { systemOneEnabled: true, systemOneFastBrowser: true, typesafeApiKey: 'synthetic' });