fix(catalog): floored gpt-5.6 codex context window at 372k

Codex discovery under-reports the gpt-5.6 sol/terra/luna window: some
accounts omit `context_window`, others actively return 272000. The #5707
`?? fallback` only fired on absence, so an actively-reported 272000 passed
through and `preferDiscoveryLimit` overwrote the bundled 372K pin at
runtime, dropping compaction from 279000 to 204000 tokens.

Treat GPT_5_6_CONTEXT_WINDOW as a floor for these SKUs via Math.max so
neither omission nor active under-report regresses the real capacity;
other models keep honoring the reported value. Corrected the stale
"omits" comments in codex.ts and generated-policies.ts.

Fixes #6259
This commit is contained in:
roboomp
2026-07-22 04:03:25 +00:00
parent 7b141199d5
commit 930bb33f4a
4 changed files with 66 additions and 15 deletions
@@ -364,9 +364,9 @@ function applyOpenAICatalogPolicy(model: ModelSpec<Api>, parsedModel: OpenAIMode
}
// GPT-5.6 luna/sol/terra on the Codex transport: OpenAI's Codex model
// registry declares context_window = max_context_window = 372000, but Codex
// discovery omits `context_window` for these SKUs and falls back to
// DEFAULT_CONTEXT_WINDOW (272000, src/discovery/codex.ts), which regressed
// the bundled hard capacity (#5705). Pin the true 372K input window.
// discovery under-reports it — omitting the field for some accounts and
// actively returning 272000 for others (#5705, #6259). Pin the true 372K
// input window on the bundled catalog; discovery enforces the same floor.
if (model.api === "openai-codex-responses" && semverEqual(parsedModel.version, "5.6")) {
model.contextWindow = 372000;
}