fix: surface when a response is truncated by the output limit - #830
Open
northwang-lucky wants to merge 1 commit into
Open
northwang-lucky wants to merge 1 commit into
northwang-lucky wants to merge 1 commit into
Conversation
- Add getAssistantTruncationNotice() pure function mirroring getAssistantErrorMessage() - Render a yellow inline banner on assistant messages with stopReason=length - Fix the empty-content guard so thinking-only truncated messages are not hidden - Fix ChatWindow finalAnswerMessage classification to treat truncation as terminal - Add 5 test cases (3 pure-function, 2 component-rendering) for the new seam
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.
The problem (observed in real use). When an assistant turn ends on
stopReason: "length"— e.g. a thinking model spending the entire output budget on reasoning — the conversation stops with no visible answer and no warning; the UI just sits on the last thinking block. It reads exactly like a hung session. We hit this with a 128K-token reasoning-only truncation on a long session: the model never produced a final message, and nothing in the UI said so.The fix. Mirrors the existing provider-error handling:
getAssistantTruncationNotice()inlib/message-display.ts— a pure function besidegetAssistantErrorMessage(): non-streaming +stopReason === "length"-> a short notice.stopReasonreachesMessageViewintact on both the live event path (normalizeToolCallspreserves it through the spread) and the history path (verified).MessageView), including the thinking-only-truncated case; classified alongside errors in the final-answer logic (ChatWindow) so the message is never silently dropped.Notice copy: "This response was cut off after reaching the model's output limit. Send a follow-up to continue."
Tests. 5 new cases (3 on the pure function covering the discriminating states, 2 real-render cases on
MessageViewincluding thinking-only).tsc/eslintclean; 1025 tests pass on this branch.Found while building the programmatic dispatch API discussed in #829 — unrelated to that design, so it ships standalone.