← Back to PRs

#6053: fix: use 400K context window instead of 200K if the model allows (gpt-5.2)

by icedac open 2026-02-01 07:05 View on GitHub →
agents
## Summary - OpenAI Codex models (`openai-codex/gpt-5.2`) have 400k context windows - Sessions were auto-clearing at ~200k because `lookupContextTokens()` returned `undefined` for prefixed model IDs - Added static fallback lookup using `MODEL_CONTEXT_WINDOWS` from `opencode-zen-models.ts` ## Changes - Export `MODEL_CONTEXT_WINDOWS` from `opencode-zen-models.ts` - Add static fallback in `lookupContextTokens()` for cache misses - Handle prefixed model IDs by extracting bare model ID (e.g., `openai-codex/gpt-5.2` → `gpt-5.2`) ## Test plan - [x] `pnpm build` passes - [x] `pnpm test` passes (4924 tests) - [x] `pnpm lint` passes for changed files - [ ] Manual: verify `openai-codex/gpt-5.2` sessions don't clear at 200k 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR fixes incorrect context window inference for OpenAI Codex model refs like `openai-codex/gpt-5.2` by adding a static fallback lookup in `lookupContextTokens()` when the dynamic models cache misses. It also exports `MODEL_CONTEXT_WINDOWS` from the OpenCode Zen model catalog so that context window defaults can be reused, and updates the xhigh-thinking allowlist to include the new `openai-codex/gpt-5.2` ref. Overall, the change is consistent with the existing “best-effort cache, then fallback” approach used in model discovery, and should prevent sessions from auto-clearing early when the configured model id includes a provider prefix. <h3>Confidence Score: 4/5</h3> - This PR is low-risk and likely safe to merge, with a minor normalization edge case to consider. - Changes are small, covered by existing test suite per the PR description, and primarily add a fallback read path. The main residual risk is that model IDs may include more complex prefixes/suffixes than a single `/` segment, in which case the fallback may still miss. - src/agents/context.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs