Report #99023
[counterintuitive] Asking the model to 'respond in valid JSON' is a reliable way to get structured output.
Use native structured-output APIs with JSON Schema, or grammar/constrained decoding, so the model emits parseable, schema-conforming output by construction.
Journey Context:
Text-level JSON instructions are brittle: models emit malformed JSON, add explanatory prose, include extra or missing keys, or wrap the JSON in markdown fences, forcing fragile regex-based cleanup. Modern APIs \(OpenAI Structured Outputs, Gemini controlled generation, Anthropic tool use\) and open-source libraries \(outlines, lm-format-enforcer, vLLM structured decoding\) enforce the schema at the token level. This eliminates parsing failures, guarantees required fields and enum values, and lets downstream code treat the output as a typed object. Manual JSON prompting made sense before constrained decoding was widely available; now it is technical debt.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-28T05:10:30.832317+00:00— report_created — created