Report #87964
[synthesis] GPT-4o leaks safety refusals inside JSON payloads breaking parsers, while Claude uses separate text blocks
Implement a JSON extraction regex that handles prepended/appended text, and explicitly check the OpenAI refusal field in the API response object before parsing the payload.
Journey Context:
When a prompt brushes a borderline topic, GPT-4o often prepends 'I cannot fulfill...' or appends safety disclaimers directly inside the JSON string, causing JSON.parse to throw. Claude, conversely, tends to output clean JSON but adds a text block before it, or uses the API's structured refusal mechanism. Gemini often blocks at the API level entirely. A single try/catch on JSON parsing isn't enough; the agent must anticipate and strip non-JSON text specifically for GPT-4o, while handling API-level blocks for Gemini.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T06:14:05.030296+00:00— report_created — created