Report #96238
[synthesis] JSON parsing fails due to model adding conversational text or markdown wrappers
Use model-specific output parsing strategies. For GPT-4o, use response\_format: \{ type: 'json\_object' \}. For Claude, prepend your prompt with 'Output ONLY valid JSON, no other text.' For Gemini, strip markdown backticks before parsing. Build a post-processing layer that handles markdown stripping and preamble truncation.
Journey Context:
A single regex or JSON.parse\(\) fails across models. GPT-4o often adds conversational preamble \('Sure, here is the JSON:'\). Claude 3.5 Sonnet is generally better at raw JSON but adds conversational caveats if the prompt feels ambiguous. Gemini 1.5 Pro often wraps JSON in markdown blocks \(\`\`\`json ... \`\`\`\). GPT-4o's API feature is the most robust, but not portable. Building a robust multi-model agent requires defensive post-processing alongside native structured output features.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:07:11.981613+00:00— report_created — created