Repository navigation
fix(chat): say so when a reply hits the output-token limit - #667
Merged
Merged
Conversation
A provider that stops a reply at its output cap is recorded by OpenCode as finish "length" with no error, so the panel's error box never fired. When the cap was reached while the model was still reasoning, the step had no text and no tool call and the turn rendered as nothing: the chat looked like it had done nothing. Seen live on 2026-11-10, where the gateway's default model routes to a backend capped at 8192 output tokens and two first turns spent all of it thinking (output 0, reasoning 8192). lib/opencode/output-limit.ts classifies a finished assistant step as "empty" (cut off before saying or doing anything) or "truncated" (cut off after some text or a tool call), and the turn bubble shows an amber notice with the tokens spent and what to do. Steps with an error are left to the error box. Closes #665
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #665
Why
When a provider stops a reply at its output-token cap, OpenCode records
finish: "length"and sets noerror, so the panel's error box never appears. If the cap is hit while the model is still reasoning, the step has no text and no tool call, and the turn shows nothing. The chat looks like it did nothing.Seen live on 2026-11-10: the gateway's
defaultmodel routes to the Jetstream2qwen-3.8-27bbackend, which reportsmax_output_tokens: 8192. Two first turns recordedoutput: 0, reasoning: 8192after about 100 s each.What changed
lib/opencode/output-limit.ts: a pure rule that classifies a finished assistant step cut off at the limit as:empty: stopped before saying or doing anythingtruncated: stopped after some text or a tool callSteps with an error, steps still running, and user messages are ignored.
opencode-chat.tsx: the turn bubble now keeps such a step visible and shows an amber notice. For an empty step it reads "No reply: the model used its whole output budget (8.2K tokens) thinking … send again or pick another model". For a truncated step it says the reply may be incomplete.output-limit.test.ts: 10 vitest cases.This doesn't raise the cap. That limit is on the backend; reporting real limits from the gateway's
/v1/models, and the per-caller RPM throttle, are studio-system follow-ups.Testing
tsc --noEmit: cleannpm test: 104 passedpytest -q: 1148 passedNot yet seen in a browser. On
:develop, an existing conversation that hit the limit (for example one from 2026-11-10 21:15) should now show the notice when reopened.