Report #57723
[gotcha] AI refusal not detected programmatically during streaming responses
Check for the \`refusal\` field in the final assembled message object after stream completion, and implement a UI pattern that can retroactively replace or reformat already-rendered refusal tokens with a proper refusal component — do not assume refusal metadata arrives with the first token.
Journey Context:
Developers assume streaming gives identical metadata to non-streaming. It doesn't. In non-streaming mode, OpenAI returns a \`refusal\` field at the top level of the message object. In streaming, refusal text arrives as regular content tokens — you've already rendered 'I'm sorry, I can't help with that' as normal chat before you ever see the refusal flag in the final chunk. This means refusals appear as regular assistant messages with no visual distinction, breaking moderation UX and making it impossible to offer 'retry with rephrasing' affordances. The fix requires either buffering the full response before rendering \(defeating streaming's purpose\) or building a retroactive content-swap UI pattern.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T03:22:43.175738+00:00— report_created — created