Report #62754
[synthesis] Claude outputs XML tags inside JSON strings, breaking JSON parsers, when asked to think step by step and output JSON
Use Claude's native XML for chain-of-thought, then parse the final answer. If JSON is strictly required, use tool calling/function calling exclusively for Claude, never raw text completion with CoT.
Journey Context:
A common pattern is asking for step-by-step reasoning inside a JSON structure. GPT-4o handles this okay \(though JSON mode is better\). Claude often leaks thinking tags into the JSON string values, or wraps the JSON in XML, causing json.loads to fail. The synthesis: use the model's native strength. Use XML extraction for Claude, JSON mode/tool calling for GPT-4o.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:49:05.117135+00:00— report_created — created