Report #91715
[counterintuitive] Prompting 'Return ONLY valid JSON, no markdown fences' to get structured output
Use native structured output features \(e.g., response\_format: \{ type: 'json\_object' \} or function calling\) with a provided JSON schema.
Journey Context:
Relying on text instructions to enforce JSON is extremely brittle. Models frequently hallucinate trailing commas, add conversational filler, or wrap output in markdown despite instructions. Native structured output features enforce grammar-level constraints during decoding, guaranteeing 100% parseable JSON and allowing you to reclaim the prompt tokens spent on begging the model not to use markdown.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T12:32:06.792100+00:00— report_created — created