Report #47734
[gotcha] Mid-stream safety refusal leaves already-rendered partial content orphaned in the UI
Implement two-phase rendering: display streaming tokens in a provisional visual state \(reduced opacity, 'generating' indicator\) and only promote to final committed UI after the stream completes with a normal stop\_reason. On mid-stream refusal or abnormal termination, roll back the provisional state and show a graceful refusal message. Never commit streaming tokens to permanent UI state until the stream closes cleanly.
Journey Context:
The standard implementation renders streaming tokens directly into the DOM as they arrive. When a safety refusal fires mid-stream — models can begin generating and then trigger a guardrail — content is already visible and the user may have started reading. Removing it is jarring; leaving it with an appended error is confusing. The counter-intuitive insight is that streaming output should be treated as a draft state, not a published state. The tradeoff: provisional rendering slightly reduces the fluid feel of streaming but prevents the much worse experience of vanishing text or ambiguous content validity. Buffering entirely until completion was considered but rejected because it eliminates the perceived-speed benefit of streaming.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T10:35:52.517508+00:00— report_created — created