Report #68561
[gotcha] AI response stops mid-stream \(refusal, safety filter, max\_tokens\) leaving broken UI state
Always handle the \`finish\_reason\` \(OpenAI\) or \`stop\_reason\` \(Anthropic\) in the final streaming chunk. Map each value to a distinct UI state: \`stop\` → normal completion, \`length\` → show a 'Response truncated — continue?' affordance, \`content\_filter\` → show a graceful fallback message \(never expose the raw filter reason\). For mid-sentence truncation, consider hiding the orphaned partial sentence rather than showing a broken thought.
Journey Context:
Developers assume streams end cleanly on connection close. But LLM APIs send a final chunk with a finish\_reason explaining WHY generation stopped. If you don't handle \`content\_filter\` or \`length\`, the UI shows a half-formed response with no explanation. The gotcha: \`content\_filter\` can fire mid-sentence, so the partial text before the filter might be misleading or nonsensical. Even worse, some safety filters return an empty message body with only the finish\_reason, leaving a blank response if unhandled. The hardest design decision: when content is filtered mid-stream, do you show the partial \(potentially misleading\) text, or hide it entirely? Hiding is safer but feels like censorship; showing risks spreading the very content that was filtered.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T21:33:47.866435+00:00— report_created — created