Mental model
A safety alert should name the signal the system actually observed and tell the user what can happen next. A refusal, moderation flag, missing citation, and interrupted request have different causes and remedies. Treating them as one red “unsafe answer” badge hides useful distinctions and may claim that a statement is false when it is only unverified.
Theory
A moderation result is a classifier output, not a verdict about truth. The Moderation API reports fields such as an overall flagged value, category flags, and category scores. Those fields can inform an application policy, but the product must decide how a result routes: show it, hold it for review, suppress it, or offer another action. A high score for a content category says nothing by itself about whether a factual claim is supported by evidence.
A refusal is a separate response outcome. Responses streaming has typed refusal events, including refusal deltas and a completion event for the refusal part. Keep that event distinct from an application moderation decision. A user-facing refusal can explain that the request could not be fulfilled without implying that a network failed or that every related topic is prohibited. If the server marks a tool result or output for review, identify that as the product’s policy action rather than pretending the model emitted a refusal.
Factual uncertainty needs its own evidence path. If an answer has no linked source, the interface can say “No source is linked for this claim” or “Needs verification.” It should not say “Hallucination detected” unless a separate verification process found a concrete contradiction. Citation absence can mean the source mapping is incomplete; citation presence can still point to a weak, stale, or unrelated document. A provenance alert reports evidence state, not factual truth.
Transport and service failures are different again. A disconnected stream, timeout, or moderation-service error means the application lacks a completed decision. Do not turn missing data into “safe” or “unsafe.” Preserve an incomplete state, explain whether any text was already shown, and offer a retry or recovery path. Keep logs tied to a request identifier and record which policy version produced the decision so reviews can reproduce the outcome.
Trade-offs
Streaming lowers time to first text but complicates safety review. OpenAI’s streaming guidance notes that moderation results requested with a generation arrive after the full output, not with partial text deltas. If a product requires a final moderation decision before any generated text is visible, it must buffer the response and accept later first-display time. If it streams before a final decision, the product needs a documented partial-output policy, a way to stop or retract future content, and an honest account of text already displayed. A client must not present a final pass before that result exists.
Alert wording should match the user’s next step. A request refusal may need a brief explanation; a content hold may need a review status; an uncited claim may need a source link or human check; and a dropped connection may need a retry. Use concise text labels, not color alone. A routine status can be announced politely; reserve assertive interruption for an immediate problem that requires the user’s attention. Re-announcing every streamed chunk as a warning is noisy and can make real status changes harder to hear.
Quantitative model
Audit the precision of a specific warning policy on reviewed examples:
Here, is the count of warnings that human review confirmed as appropriate and is the count of warnings review judged unnecessary; both are alert counts and is a percentage. If a “needs fact check” label appears 60 times and reviewers confirm 45 of those alerts, then . The remaining 15 alerts are possible false alarms to investigate. Precision does not measure missed risks, prove that moderation categories are correct, or replace a policy decision.
Failure modes and misconceptions
Calling every uncited statement a hallucination converts missing provenance into an unsupported factual accusation. Use an evidence-gap status until a source check establishes a contradiction. Conversely, displaying a citation chip must not imply that a human verified the source or that it supports every nearby sentence.
Showing a green “passed” badge while moderation is still pending is a race between UI state and the final result. If the application must block display until review completes, buffer the output and test the fail-closed path when the moderation service times out. If the product streams early, show a pending state and stop future rendering when policy requires it; do not imply that previously displayed text was screened retroactively.
A refusal event is not a transport error. A moderation flag is not a refusal. A timeout is not evidence that a response was unsafe or safe. Keep separate status values and metrics for each path, and test retries so an old flag cannot be applied to a newer request. Avoid showing raw category scores without context: a number can look like calibrated truth confidence even when it is only one signal used by an application policy.
Decision scenario
A financial assistant streams a response while the application requests a final moderation result. Company policy says generated text must not be displayed before that result is available. Hold the response in a server-side or client-side buffer until the completed result arrives, then render it only if the application policy allows it. If moderation fails or times out, show “Safety review could not complete; retry” and preserve the request state rather than labeling the answer safe. This increases time to first display, but matches the stated disclosure policy.
If another route streams immediately, make that separate product decision explicit, distinguish “review pending” from “review passed,” and provide a way to stop additional output. The transcript should never turn an unsupported claim into a proven falsehood just because it lacks a citation.
Learning outcomes
- Distinguish model refusals, moderation signals, evidence gaps, and transport errors.
- Explain why a moderation score is an input to application policy rather than a truth label.
- Choose how to handle streaming when moderation results arrive only after generation completes.
- Audit alert precision without treating that metric as a measure of missed risks.
Implementation pattern
Keep signal types separate so rendering cannot confuse a refusal with a classifier flag or an incomplete request. This example uses text content, distinct status copy, and one live status node instead of announcing token-by-token updates.
typescripttype SafetySignal =| { kind: "refusal" }| { kind: "moderation"; action: "allow" | "review" | "block"; categories: string[] }| { kind: "evidence-gap"; claimId: string }| { kind: "service-error"; retryable: boolean };function messageFor(signal: SafetySignal): string {switch (signal.kind) {case "refusal": return "The assistant could not fulfill this request.";case "moderation":if (signal.action === "review") return "This response is awaiting a safety review.";if (signal.action === "block") return "This response was not shown under the safety policy.";return "Moderation completed; the response is available under policy.";case "evidence-gap": return "This claim has no linked source yet.";case "service-error": return signal.retryable? "Safety review could not finish. You can retry.": "Safety review failed and this response was not shown.";}}export function renderSafetySignal(panel: HTMLElement, signal: SafetySignal | null) {panel.replaceChildren();if (!signal) return;const status = document.createElement("p");status.setAttribute("role", signal.kind === "service-error" ? "alert" : "status");status.textContent = messageFor(signal);panel.append(status);}