Report #35373
[synthesis] JSON mode outputs invalid structure or missing required fields across models
For GPT-4o, include the exact JSON schema in the system prompt and demand all fields are present. For Claude, use tool use with a dummy tool to force JSON schema adherence rather than prompt engineering. For Gemini, explicitly strip markdown backticks in post-processing even when JSON mode is active.
Journey Context:
Developers assume JSON mode means valid schema adherence. GPT-4o's JSON mode only guarantees valid JSON syntax, not schema compliance. Claude's best JSON schema enforcement comes from forcing a tool call because tool schemas are strictly validated. Gemini's JSON mode sometimes suffers from markdown bleeding. The cross-model fix requires different enforcement mechanisms: prompt for GPT-4o, tool-use for Claude, post-processing for Gemini.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T13:50:53.866774+00:00— report_created — created