Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Recheck steering after translating a plan-only answer
Emre Sokulluef6e06287635
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 9ea18dc3c..29d85a797 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -27960,6 +27960,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// The user reads this answer: in their language.const shown = await this._localizedPlanForDisplay(tabId, plan, provider, costState, runId, runtimeMode);if (this._checkAbort(tabId)) return { proceed: false, message: '[Stopped by user]', reason: 'cancelled' };+ // A correction sent while the translation ran is applied, not answered.+ if (this._hasPendingSteering(tabId) || this._steeringGateSuperseded(tabId, runOptions)) {+ return { proceed: false, steeringSuperseded: true };+ }return {proceed: false,message: this._plannerTerminalMessage(shown),@@ -28265,6 +28269,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// The user reads this answer: in their language.const shown = await this._localizedPlanForDisplay(tabId, candidate, provider, costState, runId, runtimeMode);if (this._checkAbort(tabId)) return { proceed: false, message: '[Stopped by user]' };+ // A correction sent while the translation ran is applied, not answered.+ if (this._hasPendingSteering(tabId) || this._steeringGateSuperseded(tabId, runOptions)) {+ return { proceed: false, steeringSuperseded: true };+ }return {proceed: false,message: this._plannerTerminalMessage(shown),diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex f9bf46158..01ec17594 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -24996,6 +24996,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// The user reads this answer: in their language.const shown = await this._localizedPlanForDisplay(tabId, plan, provider, costState, runId, runtimeMode);if (this._checkAbort(tabId)) return { proceed: false, message: '[Stopped by user]', reason: 'cancelled' };+ // A correction sent while the translation ran is applied, not answered.+ if (this._hasPendingSteering(tabId) || this._steeringGateSuperseded(tabId, runOptions)) {+ return { proceed: false, steeringSuperseded: true };+ }return {proceed: false,message: this._plannerTerminalMessage(shown),@@ -25297,6 +25301,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// The user reads this answer: in their language.const shown = await this._localizedPlanForDisplay(tabId, candidate, provider, costState, runId, runtimeMode);if (this._checkAbort(tabId)) return { proceed: false, message: '[Stopped by user]' };+ // A correction sent while the translation ran is applied, not answered.+ if (this._hasPendingSteering(tabId) || this._steeringGateSuperseded(tabId, runOptions)) {+ return { proceed: false, steeringSuperseded: true };+ }return {proceed: false,message: this._plannerTerminalMessage(shown),diff --git a/test/plan-when-needed.mjs b/test/plan-when-needed.mjsindex b737600c4..d10feedcb 100644--- a/test/plan-when-needed.mjs+++ b/test/plan-when-needed.mjs@@ -316,7 +316,7 @@ for (const build of BUILDS) {assert.equal(planner.localizePlanFromContent(plan, 'Sorry.'), null);});- function displayFixture({ locale = 'tr', review = 'always', plan = englishPlan({ confidence: 0.5 }), translation } = {}) {+ function displayFixture({ locale = 'tr', review = 'always', plan = englishPlan({ confidence: 0.5 }), translation, onTranslate } = {}) {const provider = { promptTier: 'full', model: 'display-fixture', name: 'display-fixture', chat: async () => ({ content: '' }) };const agent = new Agent({ getActive: () => provider, getVisionProvider: async () => null });agent.setPlanReviewSettings({ mode: review });@@ -324,6 +324,7 @@ for (const build of BUILDS) {agent._chatWithCostAllowance = async (_provider, messages, _options, _cost, meta) => {calls.push(meta.generationName);if (meta.generationName !== 'planner_localize') return { content: JSON.stringify(plan) };+ onTranslate?.(agent);if (translation instanceof Error) throw translation;return { content: translation ?? JSON.stringify({ locale, summary: 'Adresi bültene abone et.',steps: [{ id: '1', action: 'E-posta alanını doldur.' }, { id: '2', action: 'Gönder ve onayı oku.' }], risks: [] }) };@@ -336,7 +337,7 @@ for (const build of BUILDS) {const message = { role: 'user', content: 'Bu sayfadaki bültene kendi e-posta adresimle kaydol.' };const tabInfo = { tabUrl: 'https://owned.test/newsletter', tabTitle: 'Newsletter' };return {- calls, reviewed,+ agent, calls, reviewed,gate: () => agent._runPlannerGate(42, message, () => {}, null, null, '', tabInfo, 'try', 'act', { locale }),intent: () => agent._runPlannerIntentGate(42, message, () => {}, null, null, '', tabInfo, 'act', { locale }),};@@ -379,6 +380,18 @@ for (const build of BUILDS) {}});+ test(`${build}: a correction sent while a plan-only answer is translated is applied, not answered`, async () => {+ const planOnly = englishPlan({ request_kind: 'plan_only', read_scope: 'none', requires_state_change: false, requires_submission: false,+ steps: [{ id: '1', action: 'Fill in the newsletter email field.' }, { id: '2', action: 'Submit and read the confirmation.' }] });+ for (const [gate, plan] of [['gate', planOnly], ['intent', { ...planOnly, confidence: undefined }]]) {+ let corrected = false;+ const f = displayFixture({ review: 'never', plan, onTranslate: () => { corrected = true; } });+ f.agent._hasPendingSteering = () => corrected;+ assert.deepEqual(await f[gate](), { proceed: false, steeringSuperseded: true }, gate);+ assert.equal(corrected, true, gate);+ }+ });+test(`${build}: a plan-only answer is translated before it is shown`, async () => {const planOnly = englishPlan({ request_kind: 'plan_only', read_scope: 'none', requires_state_change: false, requires_submission: false,steps: [{ id: '1', action: 'Fill in the newsletter email field.' }, { id: '2', action: 'Submit and read the confirmation.' }] });