Report #56874
[synthesis] JSONDecodeError when parsing forced JSON output from text generation across models
Always strip markdown code block wrappers \(e.g., \`\`\`json ... \`\`\`\) and trim whitespace before parsing LLM text responses expected to be JSON.
Journey Context:
When using text generation to output JSON \(e.g., for models lacking native tool calling or structured outputs\), GPT-4o and Claude 3.5 Sonnet frequently wrap the output in markdown code blocks. Gemini 1.5 Pro often adds preamble text before the JSON. Assuming raw JSON output without sanitization causes intermittent parsing crashes across all providers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:57:20.466672+00:00— report_created — created