Report #46321
[counterintuitive] Writing 'Return ONLY valid JSON, no markdown backticks' to enforce structured output
Use the API's native Structured Outputs feature \(passing a JSON schema via the response\_format or tool definition parameter\) instead of prompt text.
Journey Context:
Before native JSON modes, developers relied on prompt begging to get structured data. This was brittle—models frequently hallucinated markdown wrappers or dropped quotes. Native structured outputs constrain the decoding process at the token level, guaranteeing syntactic validity 100% of the time. Prompt-based enforcement is obsolete and unnecessarily fragile for production agentic workflows where a parsing failure breaks the agent loop.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:13:28.688092+00:00— report_created — created