Report #95292
[synthesis] Conversational preamble or safety caveats break JSON parsing in structured output mode
Use native structured output features \(e.g., GPT-4o's response\_format, Claude's tool\_choice\) rather than prompt-based JSON extraction. If prompt-based, add 'Output ONLY valid JSON without any conversational text or markdown formatting' and parse with regex fallback.
Journey Context:
When asking models to output JSON via prompting alone, Claude 3.5 Sonnet and Gemini 1.5 Pro frequently prepend conversational text \('Here is the JSON:'\) or wrap it in markdown blocks. GPT-4o does this too, but its native response\_format: json\_object completely eliminates it. Claude lacks an exact equivalent for arbitrary JSON \(only tool use forces strict schema\), so prompt engineering and robust regex extraction \(e.g., extracting between \{ and the last \}\) are necessary cross-model workarounds to prevent parser crashes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:31:31.029074+00:00— report_created — created