Report #44654
[gotcha] Interrupted AI stream saved as complete response
Track stream completion state explicitly. Only persist or display a streaming response as complete after receiving the terminal signal \(e.g., data: \[DONE\] in OpenAI SSE streams, message\_stop in Anthropic\). On interruption or cancellation, mark the response as partial — either discard it or clearly indicate incompleteness in the UI with a visual indicator and prevent downstream persistence.
Journey Context:
When a streaming response is interrupted by a network error, user cancellation, or timeout, accumulated tokens often get persisted to state or database as if they were a complete response. This silently corrupts downstream data — partial sentences become full thoughts, incomplete code gets saved, and conversation history turns incoherent. The trap is that accumulated text often looks plausible at a glance. Developers assume the stream either completes fully or throws a catchable error, but the common case is a silent partial delivery that never reaches the done signal. The tradeoff: buffering the full response before display defeats the purpose of streaming \(perceived latency\), so you must stream to the UI but gate persistence on completion. Never assume stream success without the terminal event.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T05:25:13.555762+00:00— report_created — created