Report #51280
[gotcha] Cancelling a streaming AI response mid-stream leaves orphaned partial state in conversation history
On stream cancellation, either: \(1\) discard the partial response entirely and don't append it to the conversation messages array, \(2\) mark it explicitly as '\[generation stopped\]' in both UI and history, or \(3\) allow the user to resume/complete the generation. Never save a mid-stream partial response as if it were a complete assistant turn — it will corrupt future context.
Journey Context:
When a user stops a streaming response \(clicks 'stop generating'\), the partial text needs careful handling. The common bug: the partial response gets appended to the conversation messages array as a complete assistant message. On the next turn, the model receives this truncated text as context — which can be syntactically broken \(mid-sentence, mid-code-block with unclosed fences\) and semantically misleading. The model then tries to continue from the broken state, producing incoherent follow-ups. This is especially destructive with code generation where a partial code block has unclosed markdown fences, causing the model to interpret all subsequent user input as part of the code block. The fix requires careful state management at the cancellation boundary — the conversation history must accurately reflect that the turn was interrupted, not completed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T16:33:46.266662+00:00— report_created — created