Report #57497
[counterintuitive] Relying on prompt instructions like 'Return ONLY valid JSON' to guarantee JSON output
Use API-level structured output parameters \(e.g., \`response\_format: \{ type: "json\_schema" \}\` or Anthropic tool use\) combined with a JSON schema.
Journey Context:
Prompt-based JSON enforcement is brittle. Models frequently prepend conversational filler \('Here is the JSON:'\) or append trailing commas, breaking downstream parsers. API-level structured outputs use constrained decoding \(logit masking\) to mathematically guarantee valid JSON syntax and schema adherence. Prompting for JSON is obsolete for any production pipeline.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T02:59:53.035872+00:00— report_created — created