Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Native OpenAI max_context_window incorrectly clamped to default context_window

Open Beginner friendly
#7,075 2 comments 0 reactions 0 assignees View on GitHub

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

bug catalog
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lidge-jun/opencodex

All issues in lidge-jun/opencodex

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.