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
openai: ChatGPT OAuth reports 400k context for long-context models #47646
When OpenAI models are used through a ChatGPT OAuth connection, OpenCode overwrites their effective context limits with 400,000 tokens. This affects multiple long-context OpenAI models whose catalog limits are approximately 1.05 million tokens, causing the TUI to substantially overstate context usage.
For example, approximately 140,000 tokens are shown as 35–36% usage instead of approximately 13–14%.
The TUI percentage arithmetic appears correct: it divides the latest token count by model.limit.context. The inflated percentage comes from the effective model limit.
Additional Context
The OpenAI provider's ChatGPT OAuth catalog transform applies a blanket override to eligible models:
This is consistently reproducible across multiple OpenAI models connected through ChatGPT OAuth. No user-defined model or provider limit overrides are configured.
This issue might be a duplicate of existing issues. Please check:
fix(openai): OAuth transform treats Codex product budget as endpoint context limit #44821: Same root cause — the ChatGPT OAuth transform applies a hardcoded 400k/272k context limit sourced from Codex catalog values, overriding the actual model limits (which are ~1.05M tokens for affected long-context models). That issue includes a controlled binary-search experiment confirming the physical endpoint accepts up to ~921k input tokens.
Ya just migrated to v2, this is happening for me too. I had 6.1 trace the cause:
"""
OpenCode v2.0.21, opencode.provider.openai registers a model transform that, when its OpenAI OAuth connection is active, applies this to eligible OpenAI models:
js
model.limit = {
...model.limit,
context: 400000,
input: 272000
}
That includes gpt-6.1-sol. It preserves the catalog’s 128K output limit but overwrites its context and input limits.
"""
Ya just migrated to v2, this is happening for me too. I had 6.1 trace the cause:
""" OpenCode v2.0.21, opencode.provider.openai registers a model transform that, when its OpenAI OAuth connection is active, applies this to eligible OpenAI models:
js model.limit = { ...model.limit, context: 400000, input: 272000 } That includes gpt-6.1-sol. It preserves the catalog’s 128K output limit but overwrites its context and input limits. """
Proposed V2 fix: #53080. It removes the blanket ChatGPT OAuth 400K/272K override so each model retains its catalog context/input limits, with regression coverage for long-context models, a fast alias, and a smaller-context model. The regression fails before the fix and passes afterward; focused tests and the full local lint/typecheck pass. The PR is ready for maintainer review.
Update: a Linux x64 build of PR head dc65500 reports 1,050,000 context / 922,000 input tokens on the ChatGPT route for GPT-6.1 Sol, Astra, Astra Fast, GPT-5.6 Sol, and GPT-5.5. This verifies effective metadata, not endpoint capacity.
Independent confirmation from another affected user would help: if you test the PR, please share the model, ChatGPT plan, effective limits, and whether ordinary longer sessions work without premature compaction or context errors. Please omit credentials and private prompts; there is no need to run a costly maximum-context probe.
The only reason this exists is so that people using their openai subscriptions in opencode have a similar experiences as you would in other harnesses like codex (as far as plan usage goes). Without the limit people complain that opencode eats their usage much faster because it doesn't compact as early.
Annoyingly for everyone we didn't make it very intuitive as to why this happens, or how to disable that and that's obviously a big failure on our part and I apologize.
Annoyingly for everyone we didn't make it very intuitive as to why this happens, or how to disable that and that's obviously a big failure on our part and I apologize.
I don't think you guys are to blame for any of this; you're just following OpenAI's criteria. Even Codex users don't know how requests beyond X tokens were charged.
I just migrated from 1.19.3, where Astra was working well for me with a 1M context window, and encountered this restriction in V2.
This is based on source inspection, not an endpoint capacity or subscription billing test. Codex can also fetch updated model metadata from the service.
In the next update u can opt out of it by just disabling the context cap plugin:
{ "plugins": ["-opencode.provider.openai-context-caps"] } // add this to ur global opencode config, the "-" disables the plugin
We are going to keep the context limits as is (with the lower cap) to decrease ur overall spend/usage. If u want to opt out just add this to ur config, also documenting it
Reacted by Nicholai Cascio, Leo Barreiro, Leandro Lucarella, Serhii K, Matt Mirus and celery
Activity
github-actions commentedon Sep 6, 2026
This issue might be a duplicate of existing issues. Please check:
russrapper15-png commentedon Sep 6, 2026
AleksQuantum commentedon Sep 30, 2026
The issue still seems to be present
marwasha commentedon Oct 1, 2026
This issue just appeared to me, v1 had the full 1mil context window
maxiedaniels commentedon Oct 1, 2026
Ya just migrated to v2, this is happening for me too. I had 6.1 trace the cause:
"""
OpenCode v2.0.21, opencode.provider.openai registers a model transform that, when its OpenAI OAuth connection is active, applies this to eligible OpenAI models:
js
model.limit = {
...model.limit,
context: 400000,
input: 272000
}
That includes gpt-6.1-sol. It preserves the catalog’s 128K output limit but overwrites its context and input limits.
"""
barreiroleo commentedon Oct 1, 2026
Just in case, the workaround for 6.1 #44821 (comment)
marwasha commentedon Oct 4, 2026
Proposed V2 fix: #53080. It removes the blanket ChatGPT OAuth 400K/272K override so each model retains its catalog context/input limits, with regression coverage for long-context models, a fast alias, and a smaller-context model. The regression fails before the fix and passes afterward; focused tests and the full local lint/typecheck pass. The PR is ready for maintainer review.
Update: a Linux x64 build of PR head dc65500 reports 1,050,000 context / 922,000 input tokens on the ChatGPT route for GPT-6.1 Sol, Astra, Astra Fast, GPT-5.6 Sol, and GPT-5.5. This verifies effective metadata, not endpoint capacity.
Independent confirmation from another affected user would help: if you test the PR, please share the model, ChatGPT plan, effective limits, and whether ordinary longer sessions work without premature compaction or context errors. Please omit credentials and private prompts; there is no need to run a costly maximum-context probe.
marwasha commentedon Oct 4, 2026
Put together the following MR to address this
#53080
nicholaicascio commentedon Oct 11, 2026
This issue just keeps getting reported and the staff always finds a reason to close it.
FYI the workaround that @barreiroleo posted works, and your agent can set it up easily.
rekram1-node commentedon Oct 12, 2026
The only reason this exists is so that people using their openai subscriptions in opencode have a similar experiences as you would in other harnesses like codex (as far as plan usage goes). Without the limit people complain that opencode eats their usage much faster because it doesn't compact as early.
Annoyingly for everyone we didn't make it very intuitive as to why this happens, or how to disable that and that's obviously a big failure on our part and I apologize.
On other notes, Openai is changing the way some of the quotas work so this may not be an issue at all soon:
https://x.com/thsottiaux/status/2109430343346581527?s=20
barreiroleo commentedon Oct 12, 2026
I don't think you guys are to blame for any of this; you're just following OpenAI's criteria. Even Codex users don't know how requests beyond X tokens were charged.
Thanks for the follow up
KaranSiddhu commentedon Oct 18, 2026
uninstall the v2 and install the v1 again - really disappointed with this
angelcervera commentedon Oct 20, 2026
I checked the current Codex source, and it distinguishes between the default context and the configurable maximum.
For GPT-6 Astra, the bundled catalog declares:
context_window: 272,000max_context_window: 872,000Codex also supports a
model_context_windowoverride, capped at the model’s maximum.I just migrated from 1.19.3, where Astra was working well for me with a 1M context window, and encountered this restriction in V2.
This is based on source inspection, not an endpoint capacity or subscription billing test. Codex can also fetch updated model metadata from the service.
dr1ss commentedon Oct 21, 2026
I confirm, Astra context is deemed smaller than what it actually is by opencode 2. starts compacting before the 272,000 mark
rekram1-node commentedon Oct 23, 2026
#58194
In the next update u can opt out of it by just disabling the context cap plugin:
We are going to keep the context limits as is (with the lower cap) to decrease ur overall spend/usage. If u want to opt out just add this to ur config, also documenting it