Repository navigation
fix(chat): say when the context limit cut an answer short - #328
Merged
Merged
Conversation
Since #294 the backend records why the model stopped in the saved message's stats (stop_reason), and "length" means the runtime ran out of context mid-answer. The UI never read it, so a truncated answer ended mid-sentence and looked complete. The live "answer_truncated" status only reached the composer's status line, where the next event replaced it. An assistant message whose stats carry stop_reason "length" now shows a quiet note under the answer, beside the existing translation note: it was cut short by the context limit, and raising the Context window gives answers more room. The response announcer says "Response cut short by the context limit" instead of "Response complete", so screen reader users get the same information. How much history is reserved for the answer is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
An answer that the runtime cut off because it ran out of context ends mid-sentence, and nothing says so. It reads as if it finished.
Root cause
Since #294 the backend records why the model stopped in the saved message's stats (
stop_reason), and"length"means the context limit ended the answer. The frontend never read that field. The liveanswer_truncatedstatus reached only the composer's status line, where the next event replaced it.Change
MessageCard: an assistant message whose stats carrystop_reason: "length"shows a quiet note under the answer, beside the existing translation note: "This answer was cut short by the context limit. Raising the Context window gives answers more room."ResponseAnnouncer: says "Response cut short by the context limit" instead of "Response complete", so screen-reader users get the same information.Compatibility and rollback
No API or data change; it reads a field the contract already carries (
GenerationStats.stop_reason). Messages saved before #294 have nostop_reasonand show nothing new. Revert the single commit to undo.Checks
npx vitest run src/features/chat/MessageCard.test.tsx src/features/chat/ChatPage.a11y.test.tsxgives 37 passed.MessageCard.tsxandResponseAnnouncer.tsxrestored fromorigin/main, the same run gives 3 failed, 34 passed. The 3 new tests fail there, so they prove the fix.scripts/check.ps1, quick tier): all 11 checks passed in 482.4 s, including vitest and tsc.Limits
stop_reason: "length", which is what fix(generation): cancel abandoned titles, skip reasoning on side calls, abort Ollama on Stop, flag truncated answers #294 writes for both runtimes.Plan item: BE-31 (UI part only)
🤖 Generated with Claude Code