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
Pass Compass config into scheduled Auto decision resolution
Emre Sokulluba266473d207
diff --git a/src/chrome/src/agent/scheduler.js b/src/chrome/src/agent/scheduler.jsindex 5154c8bac..a2734d383 100644--- a/src/chrome/src/agent/scheduler.js+++ b/src/chrome/src/agent/scheduler.js@@ -1720,7 +1720,14 @@ export class ScheduledJobManager {if (!isWatch && runMeta.completionVerdict?.outcome === 'succeeded') return { decision: 'keep', reason: 'done_verified', model: runMeta.completionVerdict.model };// The switches stay as stored: decision-config.js reads an unset one as on// in On mode and applies the Auto and Off modes.- const config = await resolveCurrentDecisionConfig(settings);+ const activeProvider = runMeta.provider+ || (job.tabId != null && this.agent?._activeProvider?.(job.tabId))+ || this.agent?._activeProvider?.()+ || this.agent?.providerManager?.getActive?.()+ || null;+ const compass = runMeta.compass+ ?? (String(activeProvider?.config?.providerName || '').trim().toLowerCase() === 'webbrain-cloud' ? activeProvider.config : null);+ const config = runMeta.decisionConfig || await resolveCurrentDecisionConfig(settings, compass);if (!this.systemOneJudge || !decisionFeatureEnabled(config, isWatch ? 'watch' : 'completion')) return skip('disabled');if (settings.strictSecretMode || runMeta.sidecarAllowed === false || runMeta.signal?.aborted) return skip('unavailable');const state = systemOneEvidenceState(job.prompt || job.resumeInstruction || job.reason || '', runMeta.evidence, isWatch ? job.watch?.systemOneBaseline : null);@@ -2461,12 +2468,15 @@ export class ScheduledJobManager {&& askRunSucceeded(result, sawFailureLikeUpdate)? 'success': null);+ const activeProvider = tabId != null ? this.agent?._activeProvider?.(tabId) : this.agent?.providerManager?.getActive?.();+ const compass = String(activeProvider?.config?.providerName || '').trim().toLowerCase() === 'webbrain-cloud' ? activeProvider.config : null;await this._complete(running, result, effectiveOutcome, {watchAlert, completionVerdict,evidence: evidence.snapshot(),judgeContext,executionId: execution.id,settings,+ compass,signal: execution.controller.signal,sidecarAllowed: runStatus !== 'cost_limit',needsUserInput: endedForUserInput,diff --git a/src/firefox/src/agent/scheduler.js b/src/firefox/src/agent/scheduler.jsindex 113711ce6..c4ba45149 100644--- a/src/firefox/src/agent/scheduler.js+++ b/src/firefox/src/agent/scheduler.js@@ -1696,7 +1696,14 @@ export class ScheduledJobManager {if (!isWatch && runMeta.completionVerdict?.outcome === 'succeeded') return { decision: 'keep', reason: 'done_verified', model: runMeta.completionVerdict.model };// The switches stay as stored: decision-config.js reads an unset one as on// in On mode and applies the Auto and Off modes.- const config = await resolveCurrentDecisionConfig(settings);+ const activeProvider = runMeta.provider+ || (job.tabId != null && this.agent?._activeProvider?.(job.tabId))+ || this.agent?._activeProvider?.()+ || this.agent?.providerManager?.getActive?.()+ || null;+ const compass = runMeta.compass+ ?? (String(activeProvider?.config?.providerName || '').trim().toLowerCase() === 'webbrain-cloud' ? activeProvider.config : null);+ const config = runMeta.decisionConfig || await resolveCurrentDecisionConfig(settings, compass);if (!this.systemOneJudge || !decisionFeatureEnabled(config, isWatch ? 'watch' : 'completion')) return skip('disabled');if (settings.strictSecretMode || runMeta.sidecarAllowed === false || runMeta.signal?.aborted) return skip('unavailable');const state = systemOneEvidenceState(job.prompt || job.resumeInstruction || job.reason || '', runMeta.evidence, isWatch ? job.watch?.systemOneBaseline : null);@@ -2437,12 +2444,15 @@ export class ScheduledJobManager {&& askRunSucceeded(result, sawFailureLikeUpdate)? 'success': null);+ const activeProvider = tabId != null ? this.agent?._activeProvider?.(tabId) : this.agent?.providerManager?.getActive?.();+ const compass = String(activeProvider?.config?.providerName || '').trim().toLowerCase() === 'webbrain-cloud' ? activeProvider.config : null;await this._complete(running, result, effectiveOutcome, {watchAlert, completionVerdict,evidence: evidence.snapshot(),judgeContext,executionId: execution.id,settings,+ compass,signal: execution.controller.signal,sidecarAllowed: runStatus !== 'cost_limit',needsUserInput: endedForUserInput,diff --git a/test/decision-mode.mjs b/test/decision-mode.mjsindex 75cf6d729..aa92232ca 100644--- a/test/decision-mode.mjs+++ b/test/decision-mode.mjs@@ -123,7 +123,7 @@ for (const build of ['chrome', 'firefox']) {const judge = { evaluate: async () => { calls++; return { model: 'judge', answers: { condition_met: { noul: .95 }, task_complete: { noul: .95 }, task_completeness: { score: 2 } } }; } };const h = makeSchedulerHarness(scheduler, { systemOneJudge: judge });const evidence = { observations: [{ data: 'Status: done' }] };- const run = (settings, source = 'watch') => h.manager._evaluateSystemOne({ source, prompt: 'Watch status', tabId: 77 }, '', 'success', { settings, evidence });+ const run = (settings, source = 'watch', runMeta = {}) => h.manager._evaluateSystemOne({ source, prompt: 'Watch status', tabId: 77 }, '', 'success', { settings, evidence, ...runMeta });assert.equal((await run({ decisionMode: 'off', systemOneEnabled: true, typesafeApiKey: 'k', systemOneWatchEnabled: true })).reason, 'disabled');assert.equal((await run({ decisionMode: 'on', decisionProvider: 'typesafe', typesafeApiKey: 'k' })).decision, 'keep', 'On checks a watch with no switch saved');assert.equal((await run({ decisionMode: 'on', decisionProvider: 'typesafe', typesafeApiKey: 'k', systemOneCompletionEnabled: false }, 'scheduled')).reason, 'disabled');@@ -133,6 +133,10 @@ for (const build of ['chrome', 'firefox']) {const verdict = await run({});if (build === 'chrome') assert.equal(verdict.decision, 'keep', 'Auto checks with the downloaded in-browser model');else assert.equal(verdict.reason, 'disabled', 'Firefox has no in-browser model');+ const compassVerdict = await run({}, 'watch', { compass: COMPASS });+ assert.equal(compassVerdict.reason, 'disabled', 'Auto with Compass leaves watches to the main model');+ const compassProviderVerdict = await run({}, 'watch', { provider: { config: { providerName: 'webbrain-cloud', ...COMPASS } } });+ assert.equal(compassProviderVerdict.reason, 'disabled', 'Auto with active Compass provider leaves watches to the main model');});});