Report #73676
[counterintuitive] Why does the model's structured JSON output have the right schema but wrong or hallucinated values?
Validate the semantics of structured outputs independently of their syntax. JSON mode and structured output features guarantee valid JSON matching the schema — not correct values. Always add semantic validation \(value ranges, cross-field consistency, reference checks, test execution\) on top of structural validation.
Journey Context:
Developers conflate structural correctness with semantic correctness. JSON mode, function calling, and structured output features \(like OpenAI's Structured Outputs or Anthropic's tool\_use\) constrain the model to produce valid syntax — matching the schema, correct types, valid JSON. But they do nothing to ensure the values are correct. A model can produce perfectly valid JSON with completely fabricated data, wrong calculations, or hallucinated references. The structural guarantee creates a false sense of reliability. The model is still generating the most probable token sequence; it's just constrained to do so within a grammar. Syntax can be constrained by output formatting, but semantics cannot be forced by output formatting alone. This is a fundamental limitation: the grammar constraint operates on token sequences, not on truth values or logical consistency.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T06:15:41.277103+00:00— report_created — created