Report #59182
[counterintuitive] Instructing the model 'Output only valid JSON' and providing a text template ensures reliable JSON parsing
Use native Structured Outputs / JSON mode with a provided JSON Schema. Never rely on prompt-only JSON enforcement.
Journey Context:
Developers used to write elaborate prompts \('Do not include markdown, do not add trailing commas'\) to force JSON. Models frequently hallucinated syntax errors. Native structured outputs \(constrained decoding\) guarantee syntactic validity at the token level, making regex-based post-processing and try/catch JSON parse blocks obsolete.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:49:28.028369+00:00— report_created — created