From 5712b134edc54875c21707260362336e04b811d5 Mon Sep 17 00:00:00 2001 From: David Brailovsky Date: Wed, 14 Oct 2026 15:19:01 +0200 Subject: [PATCH] fix(ai): use 500K context window for Codex GPT-6.1 Sol The Codex models endpoint now returns context_window=500000 for gpt-6.1-sol; other Codex models still return 272000. fixes #10840 --- packages/ai/CHANGELOG.md | 1 + packages/ai/scripts/generate-models.ts | 4 +++- packages/ai/test/supports-xhigh.test.ts | 11 ++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index f85dd5f49..bf6a2ab24 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -20,6 +20,7 @@ - Fixed OpenAI-compatible responses showing thinking after the answer when a proxy such as LiteLLM sends reasoning and content in the same stream chunk ([#10926](https://github.com/earendil-works/pi/issues/10926)) - Fixed Gemini 4 Argon requests on Google Vertex failing with "Thinking budget is not supported", and its thinking level being ignored on the Gemini API, by sending `thinkingLevel` for Gemini 4 and later models ([#10890](https://github.com/earendil-works/pi/issues/10890)) - Fixed Xiaomi MiMo models failing with a 400 at the `minimal` thinking level by sending only the documented thinking on/off toggle and exposing only the `off` and `high` levels ([#10818](https://github.com/earendil-works/pi/issues/10818)) +- Fixed `openai-codex/gpt-6.1-sol` using a 272K context window instead of the 500K window Codex now provides ([#10840](https://github.com/earendil-works/pi/issues/10840)) ## [1.2.0] - 2026-10-12 diff --git a/packages/ai/scripts/generate-models.ts b/packages/ai/scripts/generate-models.ts index 41d6e27f6..77011ddbd 100644 --- a/packages/ai/scripts/generate-models.ts +++ b/packages/ai/scripts/generate-models.ts @@ -3129,8 +3129,10 @@ async function generateModels() { // OpenAI Codex (ChatGPT OAuth) models // NOTE: These are not fetched from models.dev; we keep a small, explicit list to avoid aliases. // Older model limits are based on observed server behavior; GPT-5.6 and GPT-6 use Codex's 272k default catalog limit. + // GPT-6.1 Sol uses the 500k default returned by /backend-api/codex/models. const CODEX_BASE_URL = "https://chatgpt.com/backend-api"; const CODEX_CONTEXT = 272000; + const CODEX_GPT_61_SOL_CONTEXT = 500000; const CODEX_GPT_56_CONTEXT = 272000; const CODEX_SPARK_CONTEXT = 128000; const CODEX_MAX_TOKENS = 128000; @@ -3144,7 +3146,7 @@ async function generateModels() { reasoning: true, input: ["text", "image"], cost: withOpenAiLongContextPricing(OPENAI_STANDARD_COSTS["gpt-6.1-sol"]), - contextWindow: CODEX_CONTEXT, + contextWindow: CODEX_GPT_61_SOL_CONTEXT, maxTokens: CODEX_MAX_TOKENS, }, { diff --git a/packages/ai/test/supports-xhigh.test.ts b/packages/ai/test/supports-xhigh.test.ts index 155b2b8d9..f3f968d46 100644 --- a/packages/ai/test/supports-xhigh.test.ts +++ b/packages/ai/test/supports-xhigh.test.ts @@ -125,10 +125,11 @@ describe("getSupportedThinkingLevels", () => { }); it.each([ - ["gpt-6-sol", { input: 2, output: 10, cacheRead: 0.2, cacheWrite: 2.5 }], - ["gpt-6-luna", { input: 0.1, output: 0.5, cacheRead: 0.01, cacheWrite: 0.125 }], - ["gpt-6.1-sol", { input: 2, output: 10, cacheRead: 0.1, cacheWrite: 2.5 }], - ] as const)("includes official metadata for OpenAI and Codex %s", (modelId, cost) => { + ["gpt-6-sol", { input: 2, output: 10, cacheRead: 0.2, cacheWrite: 2.5 }, 272000], + ["gpt-6-luna", { input: 0.1, output: 0.5, cacheRead: 0.01, cacheWrite: 0.125 }, 272000], + // Codex serves GPT-6.1 Sol with a 500K default context window (#10840) + ["gpt-6.1-sol", { input: 2, output: 10, cacheRead: 0.1, cacheWrite: 2.5 }, 500000], + ] as const)("includes official metadata for OpenAI and Codex %s", (modelId, cost, codexContextWindow) => { for (const provider of ["openai", "openai-codex"] as const) { const model = getModel(provider, modelId); expect(model).toMatchObject({ @@ -145,7 +146,7 @@ describe("getSupportedThinkingLevels", () => { }, ], }, - contextWindow: 272000, + contextWindow: provider === "openai-codex" ? codexContextWindow : 272000, maxTokens: 128000, compat: { supportsAdditionalTools: true,