Default Codex context length not matching Pro plan #4672

Open
opened 2026-02-16 17:44:59 -05:00 by yindo · 23 comments
Owner

Originally created by @sam-ulrich1 on GitHub (Jan 10, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

In the code, the context length for GPT 5.2 codex shows 400,000 tokens, which is technically correct for the API, but on the pro plan for ChatGPT, I believe you only get like 250 to 260, something like that. So, if the average user signs up with ChatGPT and uses it, they are likely to hit a context error, which forces compaction. So, it would make sense to maybe detect if it's a ChatGPT versus an API integration, and then automatically configure the defaults, maybe?

Plugins

No response

OpenCode version

1.1.111

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Originally created by @sam-ulrich1 on GitHub (Jan 10, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description In the code, the context length for GPT 5.2 codex shows 400,000 tokens, which is technically correct for the API, but on the pro plan for ChatGPT, I believe you only get like 250 to 260, something like that. So, if the average user signs up with ChatGPT and uses it, they are likely to hit a context error, which forces compaction. So, it would make sense to maybe detect if it's a ChatGPT versus an API integration, and then automatically configure the defaults, maybe? ### Plugins _No response_ ### OpenCode version 1.1.111 ### Steps to reproduce _No response_ ### Screenshot and/or share link _No response_ ### Operating System _No response_ ### Terminal _No response_
yindo added the bug label 2026-02-16 17:44:59 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 10, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #6071: [BUG]: GPT 5.2 context_length_exceeded / Your input exceeds the context window of this model - reports the same context limit mismatch issue with GPT 5.2 (showing 270k tokens when API limit is 400k)

Feel free to ignore if this doesn't address your specific case.

@github-actions[bot] commented on GitHub (Jan 10, 2026): This issue might be a duplicate of existing issues. Please check: - #6071: [BUG]: GPT 5.2 context_length_exceeded / Your input exceeds the context window of this model - reports the same context limit mismatch issue with GPT 5.2 (showing 270k tokens when API limit is 400k) Feel free to ignore if this doesn't address your specific case.
Author
Owner

@sam-ulrich1 commented on GitHub (Jan 10, 2026):

To be clear, you have to compact whether you run out of context space abruptly or not. It's just that if you have plugins like OhMyOpencode, then compaction could happen earlier at a more optimal point than the last second when you fully run out of tokens. So having a correct representation of the context by default would be nice for a lot of users.

PS love the hook system, custom hooks on compaction are a god send

@sam-ulrich1 commented on GitHub (Jan 10, 2026): To be clear, you have to compact whether you run out of context space abruptly or not. It's just that if you have plugins like OhMyOpencode, then compaction could happen earlier at a more optimal point than the last second when you fully run out of tokens. So having a correct representation of the context by default would be nice for a lot of users. PS love the hook system, custom hooks on compaction are a god send
Author
Owner

@rekram1-node commented on GitHub (Jan 10, 2026):

ah okay ill look into it

@rekram1-node commented on GitHub (Jan 10, 2026): ah okay ill look into it
Author
Owner

@sam-ulrich1 commented on GitHub (Jan 10, 2026):

@rekram1-node Is there some way that I can modify my open code JSON to fix this without having to redefine all of the models and variants that come default with the new official codex integration? Just as a temporary workaround.

@sam-ulrich1 commented on GitHub (Jan 10, 2026): @rekram1-node Is there some way that I can modify my open code JSON to fix this without having to redefine all of the models and variants that come default with the new official codex integration? Just as a temporary workaround.
Author
Owner

@rekram1-node commented on GitHub (Jan 10, 2026):

ig show me ur config but u can do partial model overrides u dont need complete redefinitions

@rekram1-node commented on GitHub (Jan 10, 2026): ig show me ur config but u can do partial model overrides u dont need complete redefinitions
Author
Owner

@PSU3D0 commented on GitHub (Jan 11, 2026):

Are there docs on partial model overrides?

@PSU3D0 commented on GitHub (Jan 11, 2026): Are there docs on partial model overrides?
Author
Owner

@sam-ulrich1 commented on GitHub (Jan 11, 2026):

Updated config with and it worked. did not know that it was config merging

  "provider": {
    "openai": {
      "models": {
        "gpt-5.2": {
          "limit": { "context": 272000, "output": 128000 }
        },
        "gpt-5.2-codex": {
          "limit": { "context": 272000, "output": 128000 }
        },
        "gpt-5.1-codex-max": {
          "limit": { "context": 272000, "output": 128000 }
        },
        "gpt-5.1-codex-mini": {
          "limit": { "context": 272000, "output": 128000 }
        }
      }
    }
  }
@sam-ulrich1 commented on GitHub (Jan 11, 2026): Updated config with and it worked. did not know that it was config merging ``` "provider": { "openai": { "models": { "gpt-5.2": { "limit": { "context": 272000, "output": 128000 } }, "gpt-5.2-codex": { "limit": { "context": 272000, "output": 128000 } }, "gpt-5.1-codex-max": { "limit": { "context": 272000, "output": 128000 } }, "gpt-5.1-codex-mini": { "limit": { "context": 272000, "output": 128000 } } } } } ```
Author
Owner

@sam-ulrich1 commented on GitHub (Jan 11, 2026):

nvm it did not merge. it overwrote the defaults

@sam-ulrich1 commented on GitHub (Jan 11, 2026): nvm it did not merge. it overwrote the defaults
Author
Owner

@FBakkensen commented on GitHub (Jan 12, 2026):

I have the excact same issue, always when used just short of 270K tokens, which match the available token count when using the pro / plus sub in codex.

@FBakkensen commented on GitHub (Jan 12, 2026): I have the excact same issue, always when used just short of 270K tokens, which match the available token count when using the pro / plus sub in codex.
Author
Owner

@kostrse commented on GitHub (Jan 12, 2026):

openai and codex should probably become separate providers.

@kostrse commented on GitHub (Jan 12, 2026): `openai` and codex should probably become separate providers.
Author
Owner

@rekram1-node commented on GitHub (Jan 12, 2026):

Guys ill try to fix this real soon, does anyone have a link to where the limits are defined? If not ill try to find it

@rekram1-node commented on GitHub (Jan 12, 2026): Guys ill try to fix this real soon, does anyone have a link to where the limits are defined? If not ill try to find it
Author
Owner

@NERO2k commented on GitHub (Jan 12, 2026):

Guys ill try to fix this real soon, does anyone have a link to where the limits are defined? If not ill try to find it

This should help:
https://github.com/openai/codex/blob/main/codex-rs/core/src/models_manager/model_info.rs

@NERO2k commented on GitHub (Jan 12, 2026): > Guys ill try to fix this real soon, does anyone have a link to where the limits are defined? If not ill try to find it This should help: https://github.com/openai/codex/blob/main/codex-rs/core/src/models_manager/model_info.rs
Author
Owner

@mykola-dev commented on GitHub (Jan 13, 2026):

i use github copilot subscription and my context window is always 100k doesnt matter which model i use (even opus/gemini pro)

@mykola-dev commented on GitHub (Jan 13, 2026): i use github copilot subscription and my context window is always 100k doesnt matter which model i use (even opus/gemini pro)
Author
Owner

@kostrse commented on GitHub (Jan 14, 2026):

GPT 5.2 via OpenAI API should have 400K, right?

@kostrse commented on GitHub (Jan 14, 2026): GPT 5.2 via OpenAI API should have 400K, right?
Author
Owner

@FBakkensen commented on GitHub (Jan 14, 2026):

i use github copilot subscription and my context window is always 100k doesnt matter which model i use (even opus/gemini pro)

Yes, all models has an artificial low context window using github copilot, this is the same whether you use github copilot, or use their subscription in opencode or any other tool

@FBakkensen commented on GitHub (Jan 14, 2026): > i use github copilot subscription and my context window is always 100k doesnt matter which model i use (even opus/gemini pro) Yes, all models has an artificial low context window using github copilot, this is the same whether you use github copilot, or use their subscription in opencode or any other tool
Author
Owner

@rchybicki commented on GitHub (Jan 16, 2026):

I just hit the context length window error on gpt-5.2 using an API key at 275k tokens, so I believe it's not API vs Sub. AFAIK OpenAI's 400k is input 270k + output 130k, which is a bit misleading.

@rchybicki commented on GitHub (Jan 16, 2026): I just hit the context length window error on gpt-5.2 using an API key at 275k tokens, so I believe it's not API vs Sub. AFAIK OpenAI's 400k is input 270k + output 130k, which is a bit misleading.
Author
Owner

@rekram1-node commented on GitHub (Jan 16, 2026):

Yeah having people report this still exists, looking into it

@rekram1-node commented on GitHub (Jan 16, 2026): Yeah having people report this still exists, looking into it
Author
Owner

@brandon93s commented on GitHub (Jan 16, 2026):

@rchybicki 5.2 or 5.2 codex? I believe the input limit was only set for codex models.

@rekram1-node I did hit it again today when a tool-call boiled over the limit when it tried to add a large git diff. But, believe that's the second opportunity described in the PR where you'd need a retry post compaction since you don't know tokens in advance.

@brandon93s commented on GitHub (Jan 16, 2026): @rchybicki 5.2 or 5.2 codex? I believe the input limit was only set for codex models. @rekram1-node I did hit it again today when a tool-call boiled over the limit when it tried to add a large git diff. But, believe that's the second opportunity described in the PR where you'd need a retry post compaction since you don't know tokens in advance.
Author
Owner

@rchybicki commented on GitHub (Jan 16, 2026):

@brandon93s this was 5.2 non-codex

@rchybicki commented on GitHub (Jan 16, 2026): @brandon93s this was 5.2 non-codex
Author
Owner

@rekram1-node commented on GitHub (Jan 16, 2026):

@brandon93s I think the input thing applies to all gpt-5 models

@rekram1-node commented on GitHub (Jan 16, 2026): @brandon93s I think the input thing applies to all gpt-5 models
Author
Owner

@rekram1-node commented on GitHub (Jan 16, 2026):

Ill double check w/ their docs and update

@rekram1-node commented on GitHub (Jan 16, 2026): Ill double check w/ their docs and update
Author
Owner

@brandon93s commented on GitHub (Jan 16, 2026):

@rekram1-node confirmed here: https://github.com/openai/codex/blob/main/codex-rs/core/src/models_manager/model_info.rs#L250

@brandon93s commented on GitHub (Jan 16, 2026): @rekram1-node confirmed here: https://github.com/openai/codex/blob/main/codex-rs/core/src/models_manager/model_info.rs#L250
Author
Owner

@HyunggyuJang commented on GitHub (Feb 5, 2026):

Update from my side: I think my earlier interpretation was wrong.

I traced this to model metadata in pi-mono:
https://github.com/badlogic/pi-mono/blob/f9161c4d4e0d001ebfbd3ba98f0b89adb253260a/packages/ai/src/models.generated.ts#L5099

From that data, ChatGPT subscription-backed Codex models appear constrained (roughly 272k input / 128k output) regardless of selected variant. So the default-vs-variant limit difference I reported was likely a mistaken read.

Sorry about the confusion.

@HyunggyuJang commented on GitHub (Feb 5, 2026): Update from my side: I think my earlier interpretation was wrong. I traced this to model metadata in pi-mono: https://github.com/badlogic/pi-mono/blob/f9161c4d4e0d001ebfbd3ba98f0b89adb253260a/packages/ai/src/models.generated.ts#L5099 From that data, ChatGPT subscription-backed Codex models appear constrained (roughly 272k input / 128k output) regardless of selected variant. So the default-vs-variant limit difference I reported was likely a mistaken read. Sorry about the confusion.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4672