Report #35478
[gotcha] AI content safety refusals return empty or truncated responses that appear as bugs rather than intentional filtering
Explicitly check finish\_reason in every API response. When finish\_reason is 'content\_filter', render a distinct UI state: a friendly message explaining the content could not be generated, with a suggestion to rephrase. Never surface raw API error messages. Track content\_filter rates separately from error rates in monitoring.
Journey Context:
When OpenAI or Azure's content safety filters trigger, the API returns finish\_reason: 'content\_filter' with potentially empty message content. Most error handling code treats non-'stop' finish reasons as generic errors, or worse, treats empty content as a successful empty response. The user sees either a confusing error message, a blank response, or nothing at all. They then retry the same prompt, get the same refusal, and enter a frustrating loop. This is especially bad because content filtering often triggers on legitimate user intent that brushes against safety boundaries \(e.g., medical questions, creative writing with conflict\). The fix requires: \(1\) explicitly checking finish\_reason, \(2\) mapping content\_filter to a distinct, friendly UI state that does not blame the user, \(3\) suggesting rephrasing, and \(4\) NOT counting content\_filter as an API error in your metrics \(it is working as intended\). Azure OpenAI provides more granular content filter categories \(hate, sexual, violence, self-harm\) that can inform the UI message.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:01:01.637238+00:00— report_created — created