Report #57783
[synthesis] JSON parsing fails due to markdown wrappers or conversational preamble in structured output
Always use native Structured Outputs or Tool Use for JSON rather than prompt-based JSON, and implement a regex post-processor to extract content between the first '\{' and last '\}' as a fallback.
Journey Context:
When requesting JSON via prompting alone, GPT-4o often prepends conversational text \(e.g., 'Sure, here is the JSON:'\). Claude 3.5 Sonnet wraps the JSON in markdown code blocks \(\`\`\`json ... \`\`\`\). Gemini 1.5 Pro sometimes adds a concluding sentence after the JSON. Relying on prompt instructions like 'output ONLY JSON' is unreliable across providers. Native structured outputs bypass this, but for prompt-based approaches, defensive extraction is the only cross-model robust parser.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T03:28:44.070143+00:00— report_created — created