Skip to content

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

Local proxy: a saved manual 16k is a user override, not the generic local default

Claude3935265e279d
diff --git a/src/chrome/src/providers/context-windows.js b/src/chrome/src/providers/context-windows.js
index 6dbecf2c7..5fd6cd108 100644
--- a/src/chrome/src/providers/context-windows.js
+++ b/src/chrome/src/providers/context-windows.js
@@ -82,7 +82,9 @@ export function shouldApplyDetectedContextWindow(current, detected, options = {}
if (next == null) return false;
const cur = Number(current);
if (!Number.isFinite(cur) || cur <= 0) return true;
- if (cur === DEFAULT_LOCAL_CONTEXT_WINDOW) return true;
+ // The generic 16k local default is not an override, unless the caller knows the user chose it
+ // on purpose (`explicitOverride`, e.g. a saved manual 16k for a small model behind the proxy).
+ if (cur === DEFAULT_LOCAL_CONTEXT_WINDOW && options.explicitOverride !== true) return true;
// A provider's own shipped default, or a value WebBrain filled in itself,
// is not a user override either.
if (Array.isArray(options.replaceable) && options.replaceable.some((value) => Number(value) === cur)) return true;
diff --git a/src/chrome/src/providers/manager.js b/src/chrome/src/providers/manager.js
index 95f39d3f4..b0b195fb6 100644
--- a/src/chrome/src/providers/manager.js
+++ b/src/chrome/src/providers/manager.js
@@ -2592,6 +2592,7 @@ export class ProviderManager {
if (!shouldApplyDetectedContextWindow(current?.config?.contextWindow, detected.contextWindow, {
shrinkOverride: detected.shrinkOverride === true,
replaceable: this._replaceableContextWindows(id, current?.config),
+ explicitOverride: this._hasExplicitContextWindow(id, current?.config),
})) {
return { ok: true };
}
@@ -2717,6 +2718,12 @@ export class ProviderManager {
];
}
+ // A context window the user saved on purpose for the proxy. It protects even a value that equals
+ // the generic 16k local default, which detection otherwise treats as unset.
+ _hasExplicitContextWindow(id, config) {
+ return this._providerDefinitionId(id, config) === 'local_openai_proxy' && config?.manualContextWindow === true;
+ }
+
_detectedContextWindowFields(id, config, contextWindow) {
return this._providerDefinitionId(id, config) === 'local_openai_proxy'
? { autoContextWindow: contextWindow, manualContextWindow: false }
@@ -2736,6 +2743,7 @@ export class ProviderManager {
if (!shouldApplyDetectedContextWindow(current?.config?.contextWindow, detected.contextWindow, {
shrinkOverride: detected.shrinkOverride === true,
replaceable: this._replaceableContextWindows(id, current?.config),
+ explicitOverride: this._hasExplicitContextWindow(id, current?.config),
})) {
return result;
}
diff --git a/src/firefox/src/providers/context-windows.js b/src/firefox/src/providers/context-windows.js
index 6dbecf2c7..5fd6cd108 100644
--- a/src/firefox/src/providers/context-windows.js
+++ b/src/firefox/src/providers/context-windows.js
@@ -82,7 +82,9 @@ export function shouldApplyDetectedContextWindow(current, detected, options = {}
if (next == null) return false;
const cur = Number(current);
if (!Number.isFinite(cur) || cur <= 0) return true;
- if (cur === DEFAULT_LOCAL_CONTEXT_WINDOW) return true;
+ // The generic 16k local default is not an override, unless the caller knows the user chose it
+ // on purpose (`explicitOverride`, e.g. a saved manual 16k for a small model behind the proxy).
+ if (cur === DEFAULT_LOCAL_CONTEXT_WINDOW && options.explicitOverride !== true) return true;
// A provider's own shipped default, or a value WebBrain filled in itself,
// is not a user override either.
if (Array.isArray(options.replaceable) && options.replaceable.some((value) => Number(value) === cur)) return true;
diff --git a/src/firefox/src/providers/manager.js b/src/firefox/src/providers/manager.js
index ac96203c3..652f270b8 100644
--- a/src/firefox/src/providers/manager.js
+++ b/src/firefox/src/providers/manager.js
@@ -2131,6 +2131,7 @@ export class ProviderManager {
if (!shouldApplyDetectedContextWindow(current?.config?.contextWindow, detected.contextWindow, {
shrinkOverride: detected.shrinkOverride === true,
replaceable: this._replaceableContextWindows(id, current?.config),
+ explicitOverride: this._hasExplicitContextWindow(id, current?.config),
})) {
return { ok: true };
}
@@ -2256,6 +2257,12 @@ export class ProviderManager {
];
}
+ // A context window the user saved on purpose for the proxy. It protects even a value that equals
+ // the generic 16k local default, which detection otherwise treats as unset.
+ _hasExplicitContextWindow(id, config) {
+ return this._providerDefinitionId(id, config) === 'local_openai_proxy' && config?.manualContextWindow === true;
+ }
+
_detectedContextWindowFields(id, config, contextWindow) {
return this._providerDefinitionId(id, config) === 'local_openai_proxy'
? { autoContextWindow: contextWindow, manualContextWindow: false }
@@ -2275,6 +2282,7 @@ export class ProviderManager {
if (!shouldApplyDetectedContextWindow(current?.config?.contextWindow, detected.contextWindow, {
shrinkOverride: detected.shrinkOverride === true,
replaceable: this._replaceableContextWindows(id, current?.config),
+ explicitOverride: this._hasExplicitContextWindow(id, current?.config),
})) {
return result;
}
diff --git a/test/run.js b/test/run.js
index 1c828ccb6..1882b9f31 100644
--- a/test/run.js
+++ b/test/run.js
@@ -73086,6 +73086,21 @@ test('Local OpenAI-compatible Proxy context window: model card, live props, mode
assert.equal(config().contextWindow, 65536);
}
+ // 5e''. A deliberate 16k (the generic local default) behind the proxy is a manual choice too.
+ {
+ const { mgr, config } = setup(async () => new Response('missing', { status: 404 }), {
+ model: 'claude-sonnet-4-5', contextWindow: 65536,
+ });
+ await mgr.updateProvider('local_openai_proxy', { contextWindow: 16384, manualContextWindow: true });
+ assert.equal(config().contextWindow, 16384);
+ const result = await mgr.detectProviderContextWindow('local_openai_proxy', 'claude-sonnet-4-5');
+ assert.equal(result.contextWindow, undefined, `${label}: a saved manual 16k is not enlarged by the model name`);
+ assert.equal(config().contextWindow, 16384);
+ // Without the manual marker the same 16k is the old default and is still replaced.
+ const legacy = setup(async () => new Response('missing', { status: 404 }), { model: 'claude-sonnet-4-5', contextWindow: 16384 });
+ assert.equal((await legacy.mgr.detectProviderContextWindow('local_openai_proxy', 'claude-sonnet-4-5')).contextWindow, 128000);
+ }
+
// 5f. Settings UI: edits made while detection is pending are preserved
{
const settingsSource = fs.readFileSync(path.join(ROOT, label === 'chrome' ? 'src/chrome/src/ui/settings.js' : 'src/firefox/src/ui/settings.js'), 'utf8');