Native OpenAI max_context_window incorrectly clamped to default context_window
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- backend
Research direction
The clamp is in narrowNativeMaxContextWindow() in src/codex/catalog/parsing.ts, where Math.min(value, Math.max(resolved, 1)) uses the default context_window as the limit even when no user cap is set. Read how nativeOpenAiContextWindow resolves its value, then change the function so it only narrows when a user-configured limit exists. Done when a native model such as gpt-6-astra keeps max_context_window at 872000 while context_window stays 272000.
Written by the indexing model from the issue text.
Description
Client or integration
Codex CLI
Area
Catalog / models
Summary
OpenCodex seems to incorrectly set max_context_window to the default context_window for native OpenAI models, when no user-configured context cap is applied.
For example, GPT-6 Astra should have:
{
"context_window": 272000,
"max_context_window": 872000
}
But OpenCodex produces:
{
"context_window": 272000,
"max_context_window": 272000
}
This is somewhat confusing for users who dig into the model catalog. Although the most effective setting is context_window, I think we should not cap max_context_window if it is not necessary.
Reproduction
This is the default behavior of a vanilla install, unless I configured it incorrectly by some accident.
Oneliner to show what codex gets:
$ codex debug models 2>/dev/null | jq -r '(["slug","context_window","max_context_window"] | @tsv), (.models[] | [.slug, .context_window, .max_context_window] | @tsv)' | column -t -s $'\t'
slug context_window max_context_window
gpt-6-astra 272000 272000
gpt-5.6-sol 272000 272000
gpt-5.6-terra 272000 272000
gpt-5.6-luna 272000 272000
gpt-5.5 272000 272000
gpt-6-luna 272000 272000
gpt-6-sol 272000 272000
...
Version
2.83.0
Operating system
macOS 15.7.5
Provider and model
openai login
Screenshots and supporting files
Root cause
In src/codex/catalog/parsing.ts, narrowNativeMaxContextWindow() contains:
const resolved = nativeOpenAiContextWindow(slug, limits);
return Math.min(value, Math.max(resolved, 1));
When no user cap is configured, resolved equals the default context_window, causing max_context_window to be incorrectly reduced to that value.
Suggested fix
Only narrow max_context_window when an actual user-configured limit requires it. Otherwise, preserve the model's advertised maximum.
Expected behavior
Without a user-imposed cap, native OpenAI models should retain their original max_context_window (e.g., 872K), independently of the default context_window (272K).
Checks
- I searched existing issues and documentation.
- I removed secrets, tokens, account details, request credentials, and personal data.
- Dominant language
- TypeScript
- Stars
- 16.9k
- Forks
- 1.3k
- Avg merge
- 6h 54m
- Merged PRs (30d)
- 606
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lidge-jun/opencodex
-
[Provider compatibility] volcengine-coding-plan: response.incomplete relays non-canonical incomplete_details.reason ("length")Possibly taken A pull request linked to this issue is open or already merged. Openprovider provider-compatibility streaming
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
account-pool enhancement needs-design proxy
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
lidge-jun/opencodex#6737 · 1 comment ·
Maintainers usually reply within 1 day
-
[Bug]: Codex still retries an Anthropic refusal five times because response.incomplete ignores retryable:false (follow-up to #4312)Possibly taken A pull request linked to this issue is open or already merged. Openbug streaming
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Maintainers usually reply within 1 day
-
provider provider-compatibility tools
Difficulty 4/5 3-5 days Newbie friendliness 22/100
lidge-jun/opencodex#7118 · 1 comment ·
Maintainers usually reply within 1 day
-
account-pool bug
Difficulty 4/5 3-5 days Newbie friendliness 22/100
Maintainers usually reply within 1 day
All issues in lidge-jun/opencodex
Similar issues
-
documentation good first issue
Difficulty 2/5 Half a day Newbie friendliness 72/100
sujithputta02/Esapay#13 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
ehmpathy/rhachet-roles-bhuild#468 ·
Maintainers usually reply within 1 day
-
Share dialog: the address book's contact count reads "1 contacts" (no singular form in any language)Possibly taken @chibenwa claimed this today. Openai-driven-qa bug claude Cosmetic
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
linagora/twake-contacts-frontend#271 · 1 comment ·
Maintainers usually reply within 1 day
-
factory-active task-identify-harness-labels-done task-identify-issue-type-done
Difficulty 1/5 Under an hour Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Koenkk/zigbee2mqtt#33402 ·
Maintainers usually reply within 1 day