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
Preserve manually entered 64k overrides on Local OpenAI-compatible Proxy
Emre Sokullue3c7352ec222
diff --git a/src/chrome/src/providers/manager.js b/src/chrome/src/providers/manager.jsindex 5ac4f7b91..640e9b8dd 100644--- a/src/chrome/src/providers/manager.js+++ b/src/chrome/src/providers/manager.js@@ -2026,6 +2026,7 @@ export class ProviderManager {configured: !WEBBRAIN_CLOUD_PROVIDER_IDS.has(id) && (markConfigured || current.configured === true),};if (Object.hasOwn(updates, 'contextWindow')) {+ merged.manualContextWindow = true;if (!Number.isFinite(Number(current.contextWindow))|| Number(updates.contextWindow) !== Number(current.contextWindow)|| Number(updates.contextWindow) !== Number(current.autoContextWindow)) {@@ -2682,21 +2683,25 @@ export class ProviderManager {/*** Stored windows that detection may replace besides the 16k local default.- * For the Local OpenAI-compatible Proxy: its own 64k default and the last- * window WebBrain filled in itself (`autoContextWindow`), so a name-based- * 128k for one model does not stick when an unknown model is picked next.- * Any other value is a user override.+ * For the Local OpenAI-compatible Proxy: its own 64k default (unless the+ * user manually saved a context window) and the last window WebBrain filled+ * in itself (`autoContextWindow`), so a name-based 128k for one model does+ * not stick when an unknown model is picked next. Any other value is a user override.*/_replaceableContextWindows(id, config) {if (this._providerDefinitionId(id, config) !== 'local_openai_proxy') return [];const auto = Number(config?.autoContextWindow);const matchesCurrent = Number(config?.contextWindow) === auto;- return [LOCAL_OPENAI_PROXY_CONTEXT_WINDOW, ...(Number.isFinite(auto) && auto > 0 && matchesCurrent ? [auto] : [])];+ const isUntouchedDefault = config?.manualContextWindow !== true && !Number.isFinite(auto);+ return [+ ...(isUntouchedDefault ? [LOCAL_OPENAI_PROXY_CONTEXT_WINDOW] : []),+ ...(Number.isFinite(auto) && auto > 0 && matchesCurrent ? [auto] : []),+ ];}_detectedContextWindowFields(id, config, contextWindow) {return this._providerDefinitionId(id, config) === 'local_openai_proxy'- ? { autoContextWindow: contextWindow }+ ? { autoContextWindow: contextWindow, manualContextWindow: false }: {};}diff --git a/src/firefox/src/providers/manager.js b/src/firefox/src/providers/manager.jsindex bdbbdb37e..c561feffa 100644--- a/src/firefox/src/providers/manager.js+++ b/src/firefox/src/providers/manager.js@@ -1607,6 +1607,7 @@ export class ProviderManager {configured: !WEBBRAIN_CLOUD_PROVIDER_IDS.has(id) && (markConfigured || current.configured === true),};if (Object.hasOwn(updates, 'contextWindow')) {+ merged.manualContextWindow = true;if (!Number.isFinite(Number(current.contextWindow))|| Number(updates.contextWindow) !== Number(current.contextWindow)|| Number(updates.contextWindow) !== Number(current.autoContextWindow)) {@@ -2221,21 +2222,25 @@ export class ProviderManager {/*** Stored windows that detection may replace besides the 16k local default.- * For the Local OpenAI-compatible Proxy: its own 64k default and the last- * window WebBrain filled in itself (`autoContextWindow`), so a name-based- * 128k for one model does not stick when an unknown model is picked next.- * Any other value is a user override.+ * For the Local OpenAI-compatible Proxy: its own 64k default (unless the+ * user manually saved a context window) and the last window WebBrain filled+ * in itself (`autoContextWindow`), so a name-based 128k for one model does+ * not stick when an unknown model is picked next. Any other value is a user override.*/_replaceableContextWindows(id, config) {if (this._providerDefinitionId(id, config) !== 'local_openai_proxy') return [];const auto = Number(config?.autoContextWindow);const matchesCurrent = Number(config?.contextWindow) === auto;- return [LOCAL_OPENAI_PROXY_CONTEXT_WINDOW, ...(Number.isFinite(auto) && auto > 0 && matchesCurrent ? [auto] : [])];+ const isUntouchedDefault = config?.manualContextWindow !== true && !Number.isFinite(auto);+ return [+ ...(isUntouchedDefault ? [LOCAL_OPENAI_PROXY_CONTEXT_WINDOW] : []),+ ...(Number.isFinite(auto) && auto > 0 && matchesCurrent ? [auto] : []),+ ];}_detectedContextWindowFields(id, config, contextWindow) {return this._providerDefinitionId(id, config) === 'local_openai_proxy'- ? { autoContextWindow: contextWindow }+ ? { autoContextWindow: contextWindow, manualContextWindow: false }: {};}diff --git a/test/run.js b/test/run.jsindex cb8eed851..3423cc25d 100644--- a/test/run.js+++ b/test/run.js@@ -73020,6 +73020,21 @@ test('Local OpenAI-compatible Proxy context window: model card, live props, modeassert.equal(config().contextWindow, 128000);}+ // 5c. A manually entered 64k context window is preserved as a user override+ // and not enlarged by name-based detection.+ {+ const { mgr, config } = setup(async () => new Response('missing', { status: 404 }), {+ model: 'claude-sonnet-4-5',+ });+ await mgr.updateProvider('local_openai_proxy', { contextWindow: 65536 });+ assert.equal(config().contextWindow, 65536);+ assert.equal(config().manualContextWindow, true, `${label}: manual 64k recorded as manualContextWindow`);+ assert.equal(config().autoContextWindow, undefined);+ const result = await mgr.detectProviderContextWindow('local_openai_proxy', 'claude-sonnet-4-5');+ assert.equal(result.contextWindow, undefined, `${label}: manual 64k override is preserved against name inference`);+ assert.equal(config().contextWindow, 65536);+ }+// 6. A manual override is never enlarged by a name or the fallback...{const { mgr, config } = setup(async () => new Response('missing', { status: 404 }), {