# Why Does Structured Output Fail? An Empirical Study of Prompt-Enforced Pydantic Schemas Across Nine LLMs

DevFeed: [Why Does Structured Output Fail? An Empirical Study of Prompt-Enforced Pydantic Schemas Across Nine LLMs](<https://devfeed.tech/articles/why-does-structured-output-fail-an-empirical-study-of-prompt-enforced-pydantic-schemas-across-nine-llms-101757.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2610.33949>)

Author: Amit Verma

Published: 2026-10-27T04:00:00Z

Content type: article

Language: en

Sources: [arXiv: Software Engineering](<https://devfeed.tech/sources/arxiv-software-engineering.md>)

Topics: [prompt](<https://devfeed.tech/topics/prompt.md>), [Prompt Engineering](<https://devfeed.tech/topics/prompt-engineering.md>), [Pydantic](<https://devfeed.tech/topics/pydantic.md>), [schema design](<https://devfeed.tech/topics/schema-design.md>), [LLM observability](<https://devfeed.tech/topics/llm-observability.md>), [text-generation](<https://devfeed.tech/topics/text-generation.md>)

Tags: [ablation](<https://devfeed.tech/tags/ablation.md>), [abstract](<https://devfeed.tech/tags/abstract.md>), [aggregate](<https://devfeed.tech/tags/aggregate.md>), [annotations](<https://devfeed.tech/tags/annotations.md>), [anthropic](<https://devfeed.tech/tags/anthropic.md>), [api](<https://devfeed.tech/tags/api.md>), [application](<https://devfeed.tech/tags/application.md>), [apply](<https://devfeed.tech/tags/apply.md>), [arxiv](<https://devfeed.tech/tags/arxiv.md>), [but](<https://devfeed.tech/tags/but.md>), [can](<https://devfeed.tech/tags/can.md>), [categories](<https://devfeed.tech/tags/categories.md>), [cs-cl](<https://devfeed.tech/tags/cs-cl.md>), [cs-lg](<https://devfeed.tech/tags/cs-lg.md>), [cs-se](<https://devfeed.tech/tags/cs-se.md>), [fail](<https://devfeed.tech/tags/fail.md>), [llms](<https://devfeed.tech/tags/llms.md>), [prompt](<https://devfeed.tech/tags/prompt.md>), [pydantic](<https://devfeed.tech/tags/pydantic.md>), [schemas](<https://devfeed.tech/tags/schemas.md>), [structured](<https://devfeed.tech/tags/structured.md>), [structured-output](<https://devfeed.tech/tags/structured-output.md>), [study](<https://devfeed.tech/tags/study.md>)

## AI overview

Across 3,997 attempts using nine OpenAI and Anthropic model/API configurations on HotpotQA and FinanceBench, similar validity rates concealed different schema-conformance failures, which varied by task and schema constraints. Markdown-fenced JSON was the most common failure: removing fences made only 48.0% of 681 fenced responses valid; the rest mainly contained field-length violations. In an exploratory prompt ablation, suppressing fences appeared to shift failures toward length violations, consistent with exposing existing problems rather than creating new ones. The authors derive four engineering practices for validator, schema, retry and evaluation design; three are supported by their data, while retry-feedback advice was proposed but not tested.

## Source excerpt

arXiv:2610.33949v1 Announce Type: new Abstract: Pipelines that require structured outputs from hosted language models often specify a Pydantic schema in the prompt, validate the response, and retry when validation fails. Although native structured-output modes provide an alternative, application-side validation remains important for enforcing custom constraints. Yet pipeline reliability is often summarized by a single validity rate, which obscures why outputs fail and which interventions may help. We introduce a fine-grained taxonomy of schema-conformance failures and a deterministic classifier that assigns failure categories from model responses and Pydantic validation errors. We apply this framework to 3,997 generation attempts across nine OpenAI and Anthropic model/API configurations, using questions from HotpotQA and FinanceBench. Our results show that similar validity rates can mask different failure patterns, and that dominant failure categories vary with schema constraints and task. Markdown-fenced JSON is the most common failure: among 681 fenced failures, only 48.0% pass validation after fence removal, while the remainder conceal additional violations, predominantly field-length violations. In an exploratory prompt ablation, variants that suppress fences appear to shift failures toward length violations, but the shift is consistent with exposing violations that were already present, illustrating how aggregate validity rates can obscure changes in failure composition. We derive four engineering practices for validator, schema, retry and evaluation design, three supported by our data and one, on retry feedback, proposed but not tested, and release the classifier, completions, and annotations.