JSON Schema Field Order Silently Breaks AI Structured Output Reasoning
When using strict structured outputs with LLMs, the order in which fields are declared in a JSON Schema directly controls the order tokens are generated, because constrained decoding compiles schemas into finite-state machines. If a label or classification field appears before a rationale field, the model samples its answer before any reasoning tokens exist in context, making subsequent explanations post-hoc justifications rather than genuine reasoning. This means a simple reordering of a Pydantic model—with no other changes—can measurably reduce classification accuracy while leaving rationale text looking superficially convincing. The recommended fix is to place evidence and rationale fields before label and confidence fields, effectively implementing chain-of-thought reasoning within a JSON structure. Unlike unconstrained models that may self-correct field order, strict mode enforces schema order at the logit level, removing any such fallback behavior.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in