Report #87167
[counterintuitive] Prompting 'Return ONLY valid JSON' to get structured data
Use native structured outputs and constrained decoding APIs \(e.g., json\_schema in OpenAI, tool\_use in Anthropic\) instead of prompt-based formatting.
Journey Context:
Developers used to rely on negative prompting \('DO NOT include markdown'\) to get parseable JSON. This is fragile; models frequently wrap output in markdown blocks or hallucinate missing commas. Modern APIs use constrained decoding \(grammar engines\) at the token level, making invalid JSON physically impossible to generate and eliminating the need for format-begging in the prompt.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:53:55.605149+00:00— report_created — created