Report #59283
[synthesis] JSON parsing fails because model wraps output in markdown fences or conversational preamble
Use structured outputs \(JSON mode/strict schema\) where available. For models without strict mode, append 'Output ONLY valid JSON, no markdown, no preamble' to the prompt, and use regex to strip markdown fences as a post-processing fallback.
Journey Context:
Developers often assume 'Return JSON' means pure JSON. GPT-4o defaults to markdown-wrapped JSON for readability, Claude adds polite conversational buffers. Relying on prompt alone is fragile. Structured outputs force valid JSON, but for models lacking this, a dual strategy of strict prompting plus regex extraction is the only robust cross-model solution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:00:03.354775+00:00— report_created — created