Report #21337
[counterintuitive] Prompting 'Return the result as a valid JSON object' and praying it parses
Use structured output features \(JSON mode, function calling/tool use, or response\_format\). If forced to prompt, define the schema explicitly and use prefill/assistant prefixes to start the JSON block.
Journey Context:
Early models frequently broke JSON, leading to fragile regex parsing. 'Return valid JSON' often resulted in markdown-wrapped JSON or trailing commas. Native JSON mode constrains the grammar at the sampling level, guaranteeing syntactic validity. Tool calling is even better as it maps to typed schemas.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T14:13:39.690135+00:00— report_created — created