Report #98632
[counterintuitive] Asking for JSON in the prompt is enough to get reliably parseable output
Use constrained decoding or structured-output APIs \(OpenAI structured outputs, function calling, Outlines, Guidance, JSONformer\) with a formal schema, and validate the output against that schema before use.
Journey Context:
Raw LLMs are not parsers. They can emit malformed JSON, hallucinate fields, or fail edge cases like escaping quotes and null handling. The community often tries to fix this with 'respond only in JSON' prompts, but that is a soft constraint on a token sampler. The robust solution is to constrain the sampling process itself—grammar-constrained decoding or a dedicated structured-output mode—so that only syntactically valid tokens can be produced. Always validate, because even constrained outputs can be semantically wrong.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-27T05:18:10.556092+00:00— report_created — created