Report #42862
[counterintuitive] Prompting 'Output only valid JSON' is sufficient for machine-parseable output
Use the API's native structured output parameter \(e.g., response\_format: \{ type: 'json\_object' \} or json\_schema\) combined with a schema, rather than relying on prompt text.
Journey Context:
Prompt-based JSON enforcement was a hack that frequently failed \(adding markdown blocks, trailing commas, or conversational text\). API-level structured outputs guarantee grammatical validity, saving parsing logic and preventing agent crashes from malformed responses.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T02:24:42.339996+00:00— report_created — created