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
preserve models.dev's separate input limit through the V2 LLM route
overlay openai-codex model limits onto the existing OpenAI catalog only when ChatGPT OAuth is active
compact against input - buffer and report TUI context usage against the effective input window
leave direct OpenAI API-key model limits unchanged
This prevents GPT-5.6 Sol's ChatGPT subscription route from reaching output-budget exhaustion while the TUI still reports roughly 35% context usage. The canonical numbers live in anomalyco/models.dev#3754; OpenCode only selects and enforces the route-specific metadata.
@rekram1-node, the observed failure was repeated truncated patch JSON around 372K tokens. The provider returned max_output_tokens, V2 continued the malformed call, and manual compaction was the only escape. With the Codex input window applied, default auto-compaction begins at 252K (272K input minus the 20K buffer).
Verification
packages/core: 38 focused tests pass across model resolution, OpenAI catalog routing, and compaction
packages/tui: 4 context-usage tests pass
packages/ai: GOMAXPROCS=2 bun typecheck
package-wide Core/TUI typechecks remain blocked by existing generated SDK drift; no errors reference the changed limit or TUI usage code
read-only DB backup: 19 completed auto-compactions in one affected session
17/19 occurred at 33–36% displayed usage
preceding provider usage consistently clustered at 370k–375k tokens
That is the 372k Codex input ceiling divided by the stale 1.05M public catalog window. #32119 alone would only change the display to ~40%; the credential-specific route limit is required.
One edge worth covering: OpenAIPlugin.load() currently calls connection.resolve() and catches refresh failure as undefined. For an expired OAuth credential, a transient refresh failure sets chatgpt = false; a later successful request-time refresh may not emit ConnectionUpdated, leaving public limits until another catalog reload. Reading stored credential/method type without refresh (or retaining ChatGPT route identity on refresh failure) would keep catalog metadata independent of token validity.
Rebased replacement: #39545. It preserves Kit’s commit authorship, resolves current v2 naming conflicts, removes the added TUI test assertion, and passes focused tests plus all 33 monorepo typechecks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
openai-codexmodel limits onto the existing OpenAI catalog only when ChatGPT OAuth is activeinput - bufferand report TUI context usage against the effective input windowThis prevents GPT-5.6 Sol's ChatGPT subscription route from reaching output-budget exhaustion while the TUI still reports roughly 35% context usage. The canonical numbers live in anomalyco/models.dev#3754; OpenCode only selects and enforces the route-specific metadata.
@rekram1-node, the observed failure was repeated truncated
patchJSON around 372K tokens. The provider returnedmax_output_tokens, V2 continued the malformed call, and manual compaction was the only escape. With the Codex input window applied, default auto-compaction begins at 252K (272K input minus the 20K buffer).Verification
packages/core: 38 focused tests pass across model resolution, OpenAI catalog routing, and compactionpackages/tui: 4 context-usage tests passpackages/ai:GOMAXPROCS=2 bun typecheckDepends on anomalyco/models.dev#3754.
Fixes #38851
Related: #36766, #38976
Requested by: @kitlangton (Kit via Slack)