Report #36254
[synthesis] JSON mode produces invalid schemas in Claude and Gemini but valid syntax in GPT-4o
Use GPT-4o's Structured Outputs for guaranteed syntax. For Claude and Gemini, never rely on a JSON mode toggle alone; always include a JSON schema example in the prompt and use a programmatic JSON repair library on the output before parsing.
Journey Context:
OpenAI's JSON mode guarantees valid JSON syntax. Anthropic lacks a native JSON mode toggle guaranteeing syntax; it relies on prompt engineering, and under heavy reasoning load, Claude will still occasionally output markdown blocks around the JSON. Gemini has a JSON mode but often hallucinates default values or omits required fields to make the JSON valid. Syntax guarantee is an API feature for OpenAI, but a post-processing requirement for others.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:20:07.358137+00:00— report_created — created