Report #78275
[synthesis] XML Tag Prompts Cause Malformed Outputs in Non-Anthropic Models
Use XML tags for Claude, but use JSON or Markdown schemas for GPT-4o and Gemini. If building a cross-model agent, use JSON inside a single XML tag \(e.g., '\{...\}'\) or default to native JSON modes.
Journey Context:
Anthropic's documentation recommends XML tags for structured extraction, which works beautifully for Claude. However, porting this exact prompt to GPT-4o or Gemini results in unclosed tags or mixed formatting. GPT-4o is optimized for JSON, and Gemini often drops the closing ''. The synthesis is that structural formatting must be matched to the model's tokenizer training. For cross-model compatibility, wrapping JSON in a single root XML tag \(to satisfy Claude's preference for tags\) while keeping the payload as JSON \(for GPT-4o/Gemini\) is the most robust compromise.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T13:58:55.226370+00:00— report_created — created