Skip to content

fix(chat): say when the context limit cut an answer short - #328

Merged
dovvnloading merged 1 commit into
mainfrom
fix/cut-off-answer-note
Oct 17, 2026
Merged

dovvnloading merged 1 commit into
mainfrom
fix/cut-off-answer-note

Conversation

@dovvnloading

Copy link
Copy Markdown
Owner

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 live answer_truncated status reached only the composer's status line, where the next event replaced it.

Change

  • MessageCard: an assistant message whose stats carry stop_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.
  • How much history is reserved for the answer is unchanged. That is the owner's decision under BE-31.

Compatibility and rollback

No API or data change; it reads a field the contract already carries (GenerationStats.stop_reason). Messages saved before #294 have no stop_reason and show nothing new. Revert the single commit to undo.

Checks

  • Focused tests: npx vitest run src/features/chat/MessageCard.test.tsx src/features/chat/ChatPage.a11y.test.tsx gives 37 passed.
  • Against the old components: with MessageCard.tsx and ResponseAnnouncer.tsx restored from origin/main, the same run gives 3 failed, 34 passed. The 3 new tests fail there, so they prove the fix.
  • Pre-push hook (scripts/check.ps1, quick tier): all 11 checks passed in 482.4 s, including vitest and tsc.

Limits

Plan item: BE-31 (UI part only)

🤖 Generated with Claude Code

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>
@dovvnloading
dovvnloading merged commit 1ae4975 into main Oct 17, 2026
11 checks passed
@dovvnloading
dovvnloading deleted the fix/cut-off-answer-note branch October 17, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant