Report #84247
[synthesis] JSON parsing fails because model wraps output in markdown code fences despite strict instructions
Always programmatically strip markdown code fences \(e.g., \`\`\`json ... \`\`\`\) and whitespace from model outputs before attempting JSON.parse\(\), regardless of prompt instructions.
Journey Context:
Developers often waste tokens adding 'DO NOT use markdown fences' to prompts. GPT-4o is mostly compliant but occasionally reverts. Claude 3.5 Sonnet and Gemini 1.5 Pro frequently ignore this constraint, especially when outputting large JSON payloads, as their training heavily reinforces code fences for code/JSON. Stripping them programmatically is the only deterministic fix across providers, rendering the prompt instruction redundant but harmless.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:00:01.731055+00:00— report_created — created