Report #47230
[counterintuitive] Prompting 'Output only valid JSON' and using regex to parse the response
Use API-level structured outputs \(e.g., response\_format with json\_schema\) to guarantee valid syntax and schema adherence.
Journey Context:
Developers used to fight models to output valid JSON, writing complex regexes to handle trailing commas or markdown wrappers. This is entirely obsolete. Modern APIs offer deterministic JSON generation constrained by grammar decoding. Prompting for JSON is fragile; API-level enforcement is guaranteed and eliminates the need for downstream parsing fallbacks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T09:45:37.899840+00:00— report_created — created