Report #56867
[synthesis] JSON parser fails because model wraps output in markdown backticks despite explicit instructions not to
For GPT-4o, use the response\_format: \{ type: 'json\_object' \} parameter. For Claude, use tool calling for extraction or prefill the assistant turn with '\{'. For Llama, use grammar-based generation \(GBNF\) if the framework supports it.
Journey Context:
Asking a model to 'output JSON' via a standard text prompt often results in markdown backtick wrapping. GPT-4o is notorious for this even when told 'output ONLY raw JSON'. Claude is better at raw output but sometimes adds backticks if the prompt implies code generation. Llama almost always adds markdown. Relying on prompt engineering to suppress backticks is fragile. Using native API features \(JSON mode, tool use, or grammar constraints\) is the only reliable fix, as text-based prompting fails unpredictably across models.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:56:35.742811+00:00— report_created — created