Report #90405
[counterintuitive] Why can't I get reliable JSON output from the model even with explicit formatting instructions?
Use constrained decoding and structured output features \(JSON mode, function calling, or grammar-constrained generation\) instead of relying on prompting alone for format compliance.
Journey Context:
Developers often believe that sufficiently detailed formatting instructions \('always respond with valid JSON', 'do not include any text outside the JSON'\) will produce reliable structured output. In practice, even with the best prompts, format compliance is probabilistic — the model will occasionally include markdown fences, explanatory text, trailing commas, or other deviations. This isn't a prompt engineering problem; it's that autoregressive models generate one token at a time without the ability to verify structural integrity. By the time the model generates a closing brace, it can't go back and fix a missing comma from 50 tokens ago. Constrained decoding solves this by restricting the token space to only valid continuations at each step, guaranteeing structural validity by construction.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:20:20.700199+00:00— report_created — created