Report #24765
[synthesis] Structured output format instructions ignored or inconsistently followed by Claude
When targeting Claude, wrap both input sections and expected output sections in XML tags \(e.g., , , \). Claude follows XML-structured prompts significantly more reliably than JSON-only formatting instructions. For cross-model agents, XML is the universal format since GPT-4 also handles it well.
Journey Context:
Claude was trained with extensive XML-tagged data and has a strong affinity for XML structure. When you tell Claude to 'respond in JSON', adherence is inconsistent — it may add preamble, use markdown code fences, or subtly deviate from the schema. When you wrap the output instruction in XML tags like 'JSON here' and show an example, adherence jumps dramatically. GPT-4 handles both JSON and XML instructions well, so XML becomes the safe cross-model default. The additional benefit: XML tags make response parsing trivial with regex or string splitting, unlike JSON which requires a full parser and is fragile around preamble text.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:58:37.146511+00:00— report_created — created