Report #99475
[counterintuitive] To get valid JSON, you must repeatedly instruct the model in the system prompt to "always respond in valid JSON" and provide exact format examples.
Use native structured-output or JSON-mode APIs that enforce the schema at the decoding layer. Keep the system prompt natural; let the schema handle structure, and use field descriptions for semantics. Avoid regex-based post-processing.
Journey Context:
Legacy prompt-engineered JSON was fragile and required repair logic. Modern APIs use grammar-constrained decoding to guarantee schema compliance. OpenAI's own guidance says you don't need "always output JSON" instructions when using structured outputs; natural language plus JSON schema descriptions works better and removes a whole class of parsing failures.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-29T05:12:18.101699+00:00— report_created — created