You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GPT 5.5 **SMALLER** context limits are not respected #24751
opencode uses hard coded context limits values for gpt-5.5, ignoring values set in opencode.jsonc.
I suspect it's due to PR #24212 which added this to codex.ts:
// gpt-5.5 models temporarily have restricted context window size for codex plansif(model.id.includes("gpt-5.5")){model.limit={context: 400_000,//@ts-expect-error incorrect type for v1 sdk but worksinput: 272_000,output: 128_000,}}
It should probably either overwrite only when the values are not specified in the config, or use max(400_000, model.limit.context) (same for input/output) to allow lower values (which is useful because gpt-5.5 is very expensive)
Plugins
None
OpenCode version
1.14.28
Steps to reproduce
Add this to ~/.config/opencode/opencode.jsonc in provider.openai.models:
Run opencode models openai --verbose and check context limits for both models. gpt-5.4 will respect the overrides, gpt-5.5 will not. Alternatively, start a conversation with gpt-5.5, you'll see that the context window stats are relative to 400k context window not 200k.
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Reacted by rich-jojo, JHIH-SIOU LI, 강승완 and Andrei Tarutin
Confirming this. I just chased the same bug — running openai/gpt-5.5 via Codex OAuth on a Pro/Plus plan, compaction kicks in around ~250k tokens despite the model having 922k input / 1M context.
Root cause is exactly what you identified: CodexAuthPlugin.auth.loader in packages/opencode/src/plugin/codex.ts:394-402 unconditionally replaces model.limit for any gpt-5.5 model:
So a user who only sets { context: 1050000, output: 128000 } (the natural pattern, since input is implied) silently keeps input: 272000 from the plugin hardcode. With usable() = input - reserved = 252_000, compaction triggers at the first 250k+ message.
Debug evidence — the relevant overflow check from a real session before the workaround:
Note modelLimit.input=272000 despite context=1050000 — that's the user's context override applied while input stayed at the codex hardcode.
Workaround: explicitly add all three fields to user config:
"openai": {
"models": {
"gpt-5.5": {
"limit": {
"context": 1050000,
"input": 922000, // <-- this is the field that gets silently overwritten"output": 128000
}
}
}
}
Proposed real fix: when user provides any explicit limit override, fall back to the original models.dev snapshot for unspecified fields (not to whatever a plugin auth.loader has mutated the limit to). I have an implementation on a fork: sjawhar@f4ab23a6270e — it captures the original limits before plugin loaders run, then uses them as the fallback in the override loop. The plugin still gets to enforce its restriction when no user override exists, but the user's intent wins when they have explicitly configured the model.
Tested with the same gpt-5.5 + Codex OAuth setup — compaction now correctly fires near the 902k threshold (922k input - 20k reserved) instead of 252k.
Correction to my earlier comment — my proposed "snapshot fallback" fix was wrong, and I've reverted it.
The 400k context cap on Codex (ChatGPT subscription) gpt-5.5 is server-side enforced by Codex, not just a client-side hardcode. Per OpenAI's launch announcement (Apr 23, 2026):
In Codex, GPT-5.5 is also available for Edu and Go plans with a 400K context window
The context window in Codex is 400K tokens, not the 1M available through the Chat API.
API access is coming "very soon"
So CodexAuthPlugin's hardcode {context: 400_000, input: 272_000, output: 128_000} correctly reflects what Codex actually serves. Letting users override this with snapshot defaults causes the conversation to grow past Codex's hard cap, then triggers reactive context_length_exceeded errors and emergency compaction (verified — the binary I built with the override-bypass fix produces noticeably worse behavior than the default).
The original report (this issue and #24561) appears to actually be the same Codex tier limit, not a config-respect bug. The hardcode is doing its job.
The legitimate underlying problem is: users on the developer API tier (1M context) currently can't use it because gpt-5.5 hasn't been released for general API access yet (per OpenAI's announcement). Once it ships:
API key auth (auth.type === "api"): codex.ts loader doesn't fire, so the snapshot's 1M is used → user can choose to override
For now, ChatGPT subscription users have to live with 400k context (252k usable input after the 20k compaction buffer) for gpt-5.5. That's an OpenAI product decision, not an opencode bug.
Activity
github-actions commentedon Apr 28, 2026
This issue might be a duplicate of (or closely related to) an existing issue. Please check:
codex.ts). That issue reports that the 400k Codex limit overrides the larger API limit, while this issue reports that the hardcoded values override user-configured lower limits. They are distinct symptoms but share the same underlying code.sjawhar commentedon Apr 29, 2026
Confirming this. I just chased the same bug — running
openai/gpt-5.5via Codex OAuth on a Pro/Plus plan, compaction kicks in around ~250k tokens despite the model having 922k input / 1M context.Root cause is exactly what you identified:
CodexAuthPlugin.auth.loaderinpackages/opencode/src/plugin/codex.ts:394-402unconditionally replacesmodel.limitfor anygpt-5.5model:The user-config override in
provider.tsruns after this, but only applies fields the user explicitly set:So a user who only sets
{ context: 1050000, output: 128000 }(the natural pattern, sinceinputis implied) silently keepsinput: 272000from the plugin hardcode. Withusable() = input - reserved = 252_000, compaction triggers at the first 250k+ message.Debug evidence — the relevant overflow check from a real session before the workaround:
Note
modelLimit.input=272000despitecontext=1050000— that's the user'scontextoverride applied whileinputstayed at the codex hardcode.Workaround: explicitly add all three fields to user config:
Proposed real fix: when user provides any explicit
limitoverride, fall back to the original models.dev snapshot for unspecified fields (not to whatever a plugin auth.loader has mutated the limit to). I have an implementation on a fork: sjawhar@f4ab23a6270e — it captures the original limits before plugin loaders run, then uses them as the fallback in the override loop. The plugin still gets to enforce its restriction when no user override exists, but the user's intent wins when they have explicitly configured the model.Tested with the same gpt-5.5 + Codex OAuth setup — compaction now correctly fires near the 902k threshold (922k input - 20k reserved) instead of 252k.
rekram1-node commentedon Apr 29, 2026
this is NOT a bug, this is the context limit for the openai codex oauth model right now, only the api gets the 1M context window
sjawhar commentedon Apr 29, 2026
Correction to my earlier comment — my proposed "snapshot fallback" fix was wrong, and I've reverted it.
The 400k context cap on Codex (ChatGPT subscription) gpt-5.5 is server-side enforced by Codex, not just a client-side hardcode. Per OpenAI's launch announcement (Apr 23, 2026):
So
CodexAuthPlugin's hardcode{context: 400_000, input: 272_000, output: 128_000}correctly reflects what Codex actually serves. Letting users override this with snapshot defaults causes the conversation to grow past Codex's hard cap, then triggers reactivecontext_length_exceedederrors and emergency compaction (verified — the binary I built with the override-bypass fix produces noticeably worse behavior than the default).The original report (this issue and #24561) appears to actually be the same Codex tier limit, not a config-respect bug. The hardcode is doing its job.
The legitimate underlying problem is: users on the developer API tier (1M context) currently can't use it because gpt-5.5 hasn't been released for general API access yet (per OpenAI's announcement). Once it ships:
auth.type === "api"): codex.ts loader doesn't fire, so the snapshot's 1M is used → user can choose to overrideauth.type === "oauth"): plugin enforces 400k → matches server realityFor now, ChatGPT subscription users have to live with 400k context (252k usable input after the 20k compaction buffer) for gpt-5.5. That's an OpenAI product decision, not an opencode bug.
Apologies for the earlier confusion. Reverted: sjawhar@f3872ba848b2
asaf92 commentedon Apr 29, 2026
@rekram1-node I'm not talking about 1 million context window. I'm trying to set a shorter length of 200k, and it gets changed to the hardcoded values.
rekram1-node commentedon Apr 29, 2026
Ah sorry the other notes confused me, yeah let me look at that
[-]GPT 5.5 context limits are not respected[/-][+]GPT 5.5 **SMALLER** context limits are not respected[/+]asaf-genie commentedon Apr 30, 2026
Thanks, I also changed the title to make it clear.
Do I need to open a new issue or is it possible to reopen this one?
rekram1-node commentedon Apr 30, 2026
re-opened