Report #41332
[synthesis] Model wraps JSON output in markdown fences despite JSON mode being enabled
For Gemini and GPT-4o, explicitly state 'Output raw JSON only, do not use markdown backticks' in the system prompt, even when using response\_format=\{ type: "json\_object" \}.
Journey Context:
GPT-4o's JSON mode guarantees valid JSON syntax, but sometimes includes markdown fences \(\`\`\`json ... \`\`\`\) which breaks strict JSON.parse\(\) implementations. Gemini 1.5 Pro is notorious for this, often ignoring the implicit JSON mode constraint in favor of formatting. Claude's JSON mode \(via tool use or prompting\) rarely adds fences. The 'raw JSON only' instruction is redundant for Claude but strictly necessary for Gemini/GPT-4o to prevent parsing failures in automated pipelines.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T23:51:03.802622+00:00— report_created — created