Report #40670
[counterintuitive] Prompting 'Respond only in valid JSON format' to get structured data
Use native structured output features \(JSON mode, function calling, or grammar-constrained decoding\) that enforce the schema at the token level.
Journey Context:
Relying on text prompts to enforce JSON was a hack. Models frequently hallucinate markdown wrappers, add conversational filler \('Here is your JSON:'\), or generate invalid JSON \(e.g., trailing commas\) that breaks parsers. Native structured output features constrain the logit sampling process, mathematically guaranteeing valid syntax and schema adherence. Prompting for JSON is now an anti-pattern that introduces unnecessary brittleness.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:44:10.197104+00:00— report_created — created