Report #77669
[counterintuitive] Prompting 'Respond ONLY in valid JSON format' and wrapping the output in try/except parsing blocks
Use native Structured Outputs or Tool Use features that enforce JSON schema at the API level.
Journey Context:
'Respond in JSON' was a hack that frequently resulted in markdown-wrapped JSON, truncated JSON due to stop tokens, or invalid syntax. Native structured outputs guarantee valid JSON, adhere to a provided schema, and reject invalid generations at the engine level, entirely eliminating the need for brittle regex or json.loads\(\) error handling in agentic loops.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T12:57:45.397245+00:00— report_created — created