Skip to content

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

Local proxy: scope reported-window provenance to the proxy endpoint

Claude38a98cd8f4cc
diff --git a/src/chrome/src/providers/manager.js b/src/chrome/src/providers/manager.js
index 6232172f5..560edfe8f 100644
--- a/src/chrome/src/providers/manager.js
+++ b/src/chrome/src/providers/manager.js
@@ -2059,6 +2059,7 @@ export class ProviderManager {
if (!Number.isFinite(Number(merged.autoContextWindow))) {
delete merged.autoContextWindowSource;
delete merged.autoContextWindowModel;
+ delete merged.autoContextWindowBaseUrl;
}
if (id === 'webgpu' && Object.hasOwn(updates, 'model')) {
merged.model = normalizeWebgpuModelId(merged.model);
@@ -2738,6 +2739,7 @@ export class ProviderManager {
manualContextWindow: false,
autoContextWindowSource: detected.reported === true ? 'reported' : 'inferred',
autoContextWindowModel: String(detected.model || ''),
+ autoContextWindowBaseUrl: this._contextProvenanceBaseUrl(config),
};
}
@@ -2749,7 +2751,14 @@ export class ProviderManager {
const auto = Number(config?.autoContextWindow);
return config?.autoContextWindowSource === 'reported'
&& Number.isFinite(auto) && auto > 0 && Number(config?.contextWindow) === auto
- && String(config?.autoContextWindowModel || '') === String(detected.model || '');
+ && String(config?.autoContextWindowModel || '') === String(detected.model || '')
+ && String(config?.autoContextWindowBaseUrl || '') === this._contextProvenanceBaseUrl(config);
+ }
+
+ // The endpoint a reported window belongs to: the same model name behind another Base URL is a
+ // different server, whose window the old one says nothing about.
+ _contextProvenanceBaseUrl(config) {
+ return String(config?.baseUrl || '').trim().replace(/\/+$/, '').toLowerCase();
}
async _attachDetectedContextWindow(id, provider, result, options = {}) {
diff --git a/src/firefox/src/providers/manager.js b/src/firefox/src/providers/manager.js
index 69f24e6c2..7a4c5b5a9 100644
--- a/src/firefox/src/providers/manager.js
+++ b/src/firefox/src/providers/manager.js
@@ -1640,6 +1640,7 @@ export class ProviderManager {
if (!Number.isFinite(Number(merged.autoContextWindow))) {
delete merged.autoContextWindowSource;
delete merged.autoContextWindowModel;
+ delete merged.autoContextWindowBaseUrl;
}
if (this._providerDefinitionId(id, current) === 'ollama') {
merged.visionMode = OLLAMA_VISION_MODES.has(merged.visionMode) ? merged.visionMode : 'auto';
@@ -2277,6 +2278,7 @@ export class ProviderManager {
manualContextWindow: false,
autoContextWindowSource: detected.reported === true ? 'reported' : 'inferred',
autoContextWindowModel: String(detected.model || ''),
+ autoContextWindowBaseUrl: this._contextProvenanceBaseUrl(config),
};
}
@@ -2288,7 +2290,14 @@ export class ProviderManager {
const auto = Number(config?.autoContextWindow);
return config?.autoContextWindowSource === 'reported'
&& Number.isFinite(auto) && auto > 0 && Number(config?.contextWindow) === auto
- && String(config?.autoContextWindowModel || '') === String(detected.model || '');
+ && String(config?.autoContextWindowModel || '') === String(detected.model || '')
+ && String(config?.autoContextWindowBaseUrl || '') === this._contextProvenanceBaseUrl(config);
+ }
+
+ // The endpoint a reported window belongs to: the same model name behind another Base URL is a
+ // different server, whose window the old one says nothing about.
+ _contextProvenanceBaseUrl(config) {
+ return String(config?.baseUrl || '').trim().replace(/\/+$/, '').toLowerCase();
}
async _attachDetectedContextWindow(id, provider, result, options = {}) {
diff --git a/test/run.js b/test/run.js
index 3bc97daa2..534e93f45 100644
--- a/test/run.js
+++ b/test/run.js
@@ -73117,8 +73117,15 @@ test('Local OpenAI-compatible Proxy context window: model card, live props, mode
const listFail = await mgr._attachDetectedContextWindow('local_openai_proxy', mgr.providers.get('local_openai_proxy'), { ok: true, models: [] }, { model: 'claude-sonnet-4-5' });
assert.equal(listFail.contextWindow, undefined, `${label}: Load models / Test connection keep it too`);
assert.equal(config().contextWindow, 8192);
+ // The same model name behind another Base URL is another server: the old report does not apply.
+ await mgr.updateProvider('local_openai_proxy', { baseUrl: 'http://127.0.0.1:9999/v1' });
+ const moved = await mgr.detectProviderContextWindow('local_openai_proxy', 'claude-sonnet-4-5');
+ assert.equal(moved.contextWindow, 128000, `${label}: a window reported by the old endpoint is not kept for the new one`);
+ assert.equal(config().autoContextWindowSource, 'inferred');
+ assert.equal(config().autoContextWindowBaseUrl, 'http://127.0.0.1:9999/v1');
// A user edit drops the provenance with the auto window.
await mgr.updateProvider('local_openai_proxy', { contextWindow: 4096, manualContextWindow: true });
+ assert.equal(config().autoContextWindowBaseUrl, undefined);
assert.equal(config().autoContextWindowSource, undefined);
assert.equal(config().autoContextWindowModel, undefined);
}