describe("applyDiscoveredContextWindows", () => {
it("keeps the smallest context window when the same bare model id appears under multiple providers", () => { const cache = new Map<string, number>();
applyDiscoveredContextWindows({
cache,
models: [
{ id: "gemini-3.1-pro-preview", contextWindow: 128_000 },
{ id: "gemini-3.1-pro-preview", contextWindow: 1_048_576 },
],
});
// Keep the conservative (minimum) value: this cache feeds runtime paths such // as flush thresholds and session persistence, not just /status display. // Callers with a known provider should use resolveContextTokensForModel which // tries the provider-qualified key first.
expect(cache.get("gemini-3.1-pro-preview")).toBe(128_000);
});
describe("applyConfiguredContextWindows", () => {
it("writes bare model id to cache; does not touch raw provider-qualified discovery entries", () => { // Discovery stored a provider-qualified entry; config override goes into the // bare key only. resolveContextTokensForModel now scans config directly, so // there is no need (and no benefit) to also write a synthetic qualified key. const cache = new Map<string, number>([["openrouter/anthropic/claude-opus-4-6", 1_000_000]]);
applyConfiguredContextWindows({
cache,
modelsConfig: {
providers: {
openrouter: {
models: [{ id: "anthropic/claude-opus-4-6", contextWindow: 200_000 }],
},
},
},
});
expect(cache.get("anthropic/claude-opus-4-6")).toBe(200_000); // Discovery entry is untouched — no synthetic write that could corrupt // an unrelated provider's raw slash-containing model ID.
expect(cache.get("openrouter/anthropic/claude-opus-4-6")).toBe(1_000_000);
});
it("does not write synthetic provider-qualified keys; only bare model ids go into cache", () => { // applyConfiguredContextWindows must NOT write "google-gemini-cli/gemini-3.1-pro-preview" // into the cache — that keyspace is reserved for raw discovery model IDs and // a synthetic write would overwrite unrelated entries (e.g. OpenRouter's // "google/gemini-2.5-pro" being clobbered by a Google provider config). const cache = new Map<string, number>();
cache.set("google-gemini-cli/gemini-3.1-pro-preview", 1_048_576); // discovery entry
applyConfiguredContextWindows({
cache,
modelsConfig: {
providers: { "google-gemini-cli": {
models: [{ id: "gemini-3.1-pro-preview", contextWindow: 200_000 }],
},
},
},
});
// Bare key is written.
expect(cache.get("gemini-3.1-pro-preview")).toBe(200_000); // Discovery entry is NOT overwritten.
expect(cache.get("google-gemini-cli/gemini-3.1-pro-preview")).toBe(1_048_576);
});
it("does not force 1M context for non-Anthropic providers with opus 4.7 ids", () => { const result = resolveContextTokensForModel({
provider: "github-copilot",
model: "claude-opus-4.7",
fallbackContextTokens: 128_000,
allowAsyncLoad: false,
});
expect(result).toBe(128_000);
});
it("does not force 1M context for model-only anthropic opus 4.7 ids", () => { const result = resolveContextTokensForModel({
model: "anthropic/claude-opus-4.7-20260219",
fallbackContextTokens: 200_000,
allowAsyncLoad: false,
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.