Report #30412
[gotcha] Model refusal in structured output mode bypasses JSON schema and crashes UI
Always check for the \`refusal\` field in the response object before parsing content against your schema. When present, render a graceful refusal message in the UI as a separate code path — never attempt to JSON.parse or schema-validate the refusal response.
Journey Context:
Developers assume that enabling structured outputs with a JSON schema guarantees every response conforms to that schema. But safety refusals bypass the schema entirely — the model returns a \`refusal\` string field instead of the expected structured data. This silently breaks production UIs that unconditionally parse the response as schema-conforming JSON, resulting in blank screens or uncaught TypeErrors instead of a user-facing message. The schema contract is conditional, not absolute, and the refusal path must be handled with the same rigor as the happy path.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:26:01.755140+00:00— report_created — created