Report #96677
[synthesis] Model outputs malformed JSON or fails to follow JSON schema when using complex nested structures
Use XML tags for Claude and JSON for GPT-4o/Gemini. If you must use JSON for Claude, provide a 1-2 shot example of the exact JSON structure in the system prompt.
Journey Context:
Claude was trained heavily on XML and handles deeply nested XML structures flawlessly, but often drops brackets or hallucinates keys in complex JSON. GPT-4o excels at JSON \(especially with Structured Outputs\) but struggles to close deeply nested XML tags. Gemini is agnostic but leans JSON. Writing a cross-model agent using JSON-only prompts will cause silent data loss with Claude on complex schemas, while XML prompts will cause malformed outputs in GPT-4o. Translating to the model's native format is the only robust path.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:51:36.339366+00:00— report_created — created