Report #56192
[synthesis] Model outputs JSON that fails validation due to extra fields, markdown wrapping, or ignored enums
Use OpenAI's strict: true parameter. For Claude, add 'Output ONLY valid JSON matching this schema, with no additional keys, and no markdown formatting'. For Gemini, validate enums locally and do not rely on the model to adhere to them.
Journey Context:
When building structured output pipelines, developers assume models respect JSON Schema. OpenAI's strict mode guarantees it. Claude treats the schema as a suggestion unless heavily prompted, often adding conversational wrappers or adding 'reasoning' keys. Gemini 1.5 Pro frequently overrides enum values if it thinks another value is more appropriate, ignoring the schema constraint. The fix requires model-specific post-processing: strict parsing for OpenAI, regex extraction plus validation for Claude, and enum fallback logic for Gemini.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T00:48:39.296719+00:00— report_created — created