Skip to content

fix(codex): prefer max_context_window over context_window as the usable input limit - #11179

Merged
diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.50from
excessivechaos:fix/codex-max-context-window
Aug 23, 2026
Merged

diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.50from
excessivechaos:fix/codex-max-context-window

Conversation

@excessivechaos

Copy link
Copy Markdown
Contributor

Problem

The live Codex OAuth catalog reports BOTH context_window (~272K) and max_context_window (~872K). The discovery parser's firstPositiveNumber chain reads context_window first, so every GPT-5.6 model resolves to a 272K input limit even though 272K is only the first pricing tier — the real usable window is max_context_window (872K).

Evidence that 272K is not a hard window: gpt-5.6-luna-xhigh served 380-390K input tokens with HTTP 200 (call_logs, 2026-08-20 02:45-02:48) while the 922K override was active — well past 272K with no context-overflow errors.

Consequence: the context-aware combo fallback treats codex as too-small for large conversations and reorders it behind 1M-context targets, defeating the declared priority order.

Fix

Reorder firstPositiveNumber so max_context_window wins over context_window when both are present; context_window remains the fallback for catalogs that omit the max.

Verification

  • New regression test: live-shape payload (context_window: 272000 + max_context_window: 872000) resolves inputTokenLimit: 872000.
  • End-to-end check with the real live payload: gpt-5.6-luna → 872000.
  • Focused suite: 31 passed (provider-models-discovery-split).
  • Changed-file ESLint + git diff --check clean.

Live payload keys verified directly against https://chatgpt.com/backend-api/codex/models with the account OAuth token (slug + context_window + max_context_window).

@excessivechaos

Copy link
Copy Markdown
Contributor Author

Second commit (8520787) — the parser fix alone was insufficient: the conservative discovery merge (mergeCapacityLimitConservatively = Math.min(static, live)) still capped the live 872K at the static 272K from GPT_5_6_CODEX_CAPABILITIES. Verified by reproducing the merge in-process: live 872000 + static 272000 → merged 272000.\n\nThis commit raises the static Codex OAuth catalog to contextLength: 872000, maxInputTokens: 872000 (the usable max_context_window), matching the API-block precedent (GPT_5_6_API_CAPABILITIES uses 1.05M/922K). The live value now passes through the merge: live 872000 + static 872000 → merged 872000.\n\nAlso updated codex-gpt56-catalog.test.ts (272000 → 872000). Kiro tests unaffected (separate provider, still 272K).

@diegosouzapw
diegosouzapw merged commit 7af14d2 into diegosouzapw:release/v3.8.50 Aug 23, 2026
9 of 16 checks passed
jonlwheat2-gif added a commit to jonlwheat2-gif/OmniRoute that referenced this pull request Aug 24, 2026
)

i18nUiCoverage ratchet read 99.4 vs baseline 100: recent merges
(diegosouzapw#11166/diegosouzapw#11178/diegosouzapw#11179/diegosouzapw#11224/diegosouzapw#11227/diegosouzapw#11283) shipped new UI keys without
mirroring them into the 41 non-en catalogs. Fill via the documented EN-
fallback convention (scripts/i18n/fill-missing-from-en.mjs semantics:
absent keys only, never overwrite) so every locale reaches parity;
translations can be refined in place later without touching code.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…le input limit (diegosouzapw#11179)

Validated on the combined batch board over tip e8ec7cb: static gates clean (changelog, file-size 160 frozen, complexity 2628<=2774, cognitive 1187<=1223, dead-code 408<=416, docs-counts green at 351 providers, provider-consistency 268/351/0), typecheck:core clean, 430+ focused tests green across 5 groups.

max_context_window now wins over the pricing-tier context_window in Codex catalog parsing — context-aware fallback stops demoting codex behind smaller targets. Live evidence (390K served past 272K) plus the live-shape regression test. Thank you @excessivechaos!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants