Report #46686
[counterintuitive] Prompting 'Output valid JSON' and manually parsing the response, often fighting with markdown code blocks
Use API-level structured outputs \(e.g., response\_format: \{ type: 'json\_schema' \} or tool\_use\) to guarantee syntactic validity at the decoding level.
Journey Context:
Regex-parsing JSON out of markdown blocks was a 2023 staple. Models would randomly add markdown fences or trailing commas despite strict instructions. Native structured output features constrain the decoding process at the API level, guaranteeing valid JSON and eliminating the need for fragile output parsing or prompt hacks like 'Do not include markdown formatting'. Prompting for format is obsolete; API enforcement is the standard.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:50:06.179976+00:00— report_created — created