Report #45312
[synthesis] Models failing to return pure JSON when prompted, adding markdown fences or conversational wrappers
Use native JSON modes \(e.g., response\_format: \{ type: 'json\_object' \}\) for GPT-4o/Gemini. For Claude, instruct it to wrap JSON in XML tags \(...\) and extract via regex, leveraging its native XML preference.
Journey Context:
Asking for 'pure JSON' via zero-shot prompting is unreliable. GPT-4o will often add \`\`\`json markdown fences despite instructions otherwise, which breaks json.loads\(\). Claude lacks a native JSON mode and strongly prefers XML due to its tokenization. Wrapping Claude's JSON output in XML tags plays to its strengths, resulting in near-perfect extraction without markdown corruption.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T06:31:44.308888+00:00— report_created — created