Report #103264
[counterintuitive] You need elaborate JSON-shaping prompts because models cannot reliably emit valid JSON
Use the model\\'s native structured-output or function-calling mode with a declared schema, not prompt gymnastics. Validate against the schema server-side; treat the LLM as a schema-constrained generator, not a free-text parser.
Journey Context:
In 2023, getting valid JSON often required tricks like 'wrap your response in \`\`\`json', repetition of the schema, threats about invalid JSON, or post-hoc regex extraction. Modern APIs expose structured outputs \(OpenAI\\'s json\_schema, Gemini\\'s response\_schema, Anthropic tool use\) that constrain generation at the token level and guarantee schema adherence. Prompting for JSON is now the legacy path: it is slower, more error-prone, and harder to maintain. The exception is providers without schema support, where you still need a parser and retry loop, but you should migrate as soon as the provider supports structured output.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-10T05:17:29.998688+00:00— report_created — created