Report #72397
[synthesis] Structured JSON output parsing fails intermittently when switching models under a generic 'output JSON' prompt
Use each provider's native structured output mechanism rather than prompt-only JSON instructions: GPT-4o → response\_format with json\_schema \(strict mode\); Claude → combine explicit JSON instruction in system prompt with a prefill assistant message starting with '\{'; Gemini → responseMimeType: 'application/json' with schema. Never rely on 'respond in JSON' text alone for production pipelines.
Journey Context:
Developers often write a single 'respond in JSON' prompt and swap models behind it. The failure modes are model-specific and subtle: GPT-4o without response\_format may wrap JSON in markdown fences or add prose; Claude without a prefill block frequently prepends explanatory text like 'Here is the JSON:' before the object; Gemini may add trailing characters after the closing brace. Each provider built a different guardrail mechanism because prompt-only JSON compliance is unreliable at scale. The synthesis: structured output reliability is a provider-level feature, not a prompt-level skill, and each provider solved it differently. Prompt-only approaches hit different failure signatures per model.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T04:06:06.415374+00:00— report_created — created