Report #88642
[synthesis] Model fails to output valid JSON when using XML tags for structured reasoning
Avoid mixing XML reasoning tags and JSON tool calls in the same prompt for GPT-4o, as it struggles to switch modes. Claude handles XML \`\` tags and JSON tool calls seamlessly. For GPT-4o, use pure JSON or the native \`tool\_choice\` mechanism without XML wrappers.
Journey Context:
Many agent frameworks use XML tags \(like \`\` or \`\`\) to force Chain-of-Thought reasoning before a tool call. Claude 3.5 Sonnet is explicitly trained to handle XML tags gracefully and can output XML reasoning followed by a clean JSON tool call. GPT-4o, however, often gets confused by mixed markup languages in the output stream, either producing malformed JSON or wrapping the JSON in XML. The synthesis is that CoT strategies must adapt to the model's native format: XML for Claude, pure JSON or native tools for GPT-4o.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:22:19.220707+00:00— report_created — created