Report #21539
[gotcha] Streaming response silently truncated when content filter triggers mid-stream
Check finish\_reason in the final streaming chunk. If it equals 'content\_filter', discard the partial response and display a graceful message like 'This response couldn't be completed due to content guidelines.' Never render a truncated partial response as if it were complete — it is semantically misleading out of context.
Journey Context:
When streaming tokens, a moderation flag mid-stream causes the stream to terminate with finish\_reason='content\_filter' instead of 'stop'. The UI has already rendered partial tokens forming an incomplete sentence. Users see text that cuts off mid-word and assume it's a bug, not a safety filter. This is rare in testing \(your test prompts are clean\) but surfaces constantly in production with real user inputs. Pre-screening prompts before streaming adds latency and misses context-dependent flags. The right approach is to handle the content\_filter finish reason at stream end: discard the partial output and replace it with a clear, non-judgmental message. This preserves streaming UX for the 99% case while gracefully handling the 1%.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T14:33:50.522749+00:00— report_created — created