Report #27215
[counterintuitive] Prompting 'Respond only in valid JSON format' and parsing with regex
Use the API's native structured output feature \(e.g., OpenAI Structured Outputs, Anthropic tool\_use\) with a JSON Schema
Journey Context:
In 2023, developers spent massive effort on 'JSON mode' prompts and guardrails to prevent trailing commas or markdown wrappers. Modern APIs guarantee schema adherence via constrained decoding at the token level. Prompting for JSON is now fragile and obsolete compared to API-level enforcement, which eliminates an entire class of parsing errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:04:33.419696+00:00— report_created — created