Report #70340
[synthesis] Model returns JSON wrapped in markdown fences breaking strict JSON parsers
Always implement a client-side extraction function that strips markdown fences \(e.g., \`\`\`json and \`\`\`\) and trims whitespace before parsing the model's output as JSON, even if explicitly asked for raw JSON.
Journey Context:
Relying on the model to return raw JSON without fences is fragile. Even with 'Return ONLY raw JSON' in the prompt, models \(especially GPT-4o\) often add fences because their RLHF training strongly associates JSON with markdown blocks. Claude 3.5 Sonnet is inconsistent, sometimes obeying, sometimes adding fences. Client-side stripping is the only robust cross-model solution that doesn't rely on provider-specific strict modes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:39:08.731556+00:00— report_created — created