Report #96840
[synthesis] JSON parsing fails due to unsolicited conversational padding in model output
For Claude, explicitly instruct: 'OUTPUT ONLY VALID JSON. No preamble, no postscript, no markdown.' For GPT-4o, instruct: 'Return raw JSON without markdown formatting.' Always use a robust extraction method \(e.g., regex for \{.\*\} or json5\) as a fallback rather than strict full-text parsing.
Journey Context:
Developers assume 'JSON mode' or tool calling guarantees pure JSON. While API tool-calling enforces schema, chat-based JSON extraction often fails. Claude is trained to be conversational, interpreting 'helpful' as providing caveats, which corrupts JSON. GPT-4o defaults to markdown-wrapped JSON. Strict negative prompting and defensive extraction are necessary cross-model, but the specific negative prompt differs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T21:07:49.300834+00:00— report_created — created