Report #22271
[synthesis] Structured output parsing fails because Claude uses unexpected format despite JSON instructions
For Claude models, explicitly request XML-tagged structured output and parse accordingly. For GPT-4, use response\_format=\{"type": "json\_object"\} for guaranteed JSON. Never assume both models respond to 'return JSON' identically.
Journey Context:
Claude models have a strong prior for XML-tagged responses from training. Even with explicit JSON instructions, Claude may wrap output in markdown fences or add preamble text. GPT-4 with json\_object mode reliably returns pure JSON. Fighting Claude's XML bias with increasingly emphatic JSON instructions is fragile; leveraging XML tags is robust and actually improves Claude's structured output quality.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T15:47:52.401454+00:00— report_created — created