Schema-Validated LLM Workflows: A Benchmark Protocol and Comparative Evaluation Across Six Python Implementations
Authors: Sidney Shapiro, Sanad Al-Khatib, Aurora Pinzón Arzola, Emiliano Sebastian Gonzalez Venegas, Daniel Pearson
Organizations: Dhillon School of Business, University of Lethbridge, Canada · Al Hussein Technical University, Jordan · Universidad de Guanajuato, Mexico · Universidad de Guadalajara, Mexico
Large language models are increasingly used to extract records, generate SQL, summarize reports, answer policy questions, and route operational work. At these software boundaries, parseable output is necessary but does not establish task correctness. We present a reproducible benchmark protocol, a public executable artifact, and a confirmatory live API evaluation that separate structural validity from task-specific correctness across five business workflow tasks and six Python implementation conditions: PydanticAI, LangGraph, DSPy, CrewAI, Agno, and a framework-free SDK reference. We hypothesize that (H1) schema validity and task quality are separable, (H2) structured-output binding paths are heterogeneous under a shared model and lowest-common-denominator contract, and (H3) condition-by-task interactions concentrate failures rather than shifting all tasks equally. Confirmatory analysis uses distinct task instances (100 extraction and 50 per other task, with three nested replicates) under a frozen analysis plan, yielding a 5400-row primary matrix with equivalence margins and Holm-adjusted contrasts against the SDK reference. In the eligible confirmatory run, overall schema validity was 0.684 and mean automated quality was 0.638. PydanticAI, LangGraph, and DSPy retained near-ceiling schema validity with mean quality 0.91-0.94, while the plain SDK, Agno, and CrewAI conditions were substantially lower in this package and model configuration. Schema-valid rows still produced many task-score flags, especially in extraction and compliance QA, and quality residuals show strong condition-by-task interactions (including a workflow collapse for CrewAI). Labelled ablations address retry budgets and feature-using mechanisms; primary contrasts remain system-configuration findings, not causal attributions to marketed library features.
Figures & tables
Task input and ground truth
⟶
Provider constraint and implementation condition
⟶
Shared record and evaluation
↓
Structural scorer + task-specific scorer + cost and audit fields
Figure 1: Layered evaluation path (conceptual figure). Provider constraints, framework behavior, application validation, and task scoring are distinct mechanisms. Feature-using ablations exercise validators, typed dependencies, stateful orchestration, and optimization beyond the lowest-common-denominator structured-output path.
Causal attribution only for conditions that activate the claimed mechanism.
Table 2: Research-question and hypothesis evidence boundary for the confirmatory study.
Task
Input
Required output
Structured extraction
Synthetic invoices and complaints
Typed fields, optional values, confidence, and error state
SQL generation
Question and SQLite schema
Query, explanation, referenced tables and columns, or refusal
Report summarization
Synthetic tabular and narrative report
Headline, revenue summary, risks, recommendations, and outlook
Compliance QA
Synthetic policy and question
Answer, quoted citations, confidence, unsupported-claim list, and review flag
Workflow decision
Synthetic support request
Classification, proposed tool, extracted entities, recommendation, and review flag
Table 3: Task families in the current artifact.
Condition
Confirmatory LCD mechanism
Interpretation limit
PydanticAI
Agent with a Pydantic output_type
Validators/typed deps reserved for labeled ablations.
Plain SDK
Provider JSON Schema response format followed by Pydantic parsing
Framework-free reference for provider enforcement plus local parsing.
LangGraph
Structured model call wrapped in a small retry graph
Does not test a stateful business process or human interrupt.
DSPy
Untuned typed signature and Predict with application coercion
Does not test metric-driven optimization.
CrewAI
One agent and one task with output_pydantic
Does not test delegation or multi-agent coordination.
Agno
One agent with a Pydantic output schema
Does not test tools, teams, or workflow state.
Table 4: Mechanisms exercised by the confirmatory lowest-common-denominator matrix.
Task
Confirmatory primary score
Hardening in the artifact
Extraction
Macro-average of normalized field matches
Distinct layouts/templates with template_id ; label-derivability tests
SQL
Result-set equality under read-only checks
Separate fresh DBs for predicted vs gold; reject non-SELECT writes
Summarization
Source-fact coverage with unsupported-content penalty
Forbidden-term penalty in quality score; blinded review packet
Compliance QA
Answer/citation support with unsupported-claim penalty
Claim-grounding scores beyond empty-list exact match
Workflow
Decision fields plus tool execution and state-path match
Shared tool stubs and expected state paths scored on every row
Table 5: Task-specific confirmatory scorers and hardening implemented in the executable artifact.
Task
Instances
Approx. MDE (quality)
Equiv. power @ 0
Notes
Extraction
100
0.024
0.999
3 nested replicates
SQL generation
50
0.034
0.986
Distinct DB per instance
Summarization
50
0.034
0.986
Unsupported-content penalty
Compliance QA
50
0.034
0.986
Claim grounding
Workflow
50
0.034
0.986
Executed tool/state scoring
Table 6: Frozen instance-clustered power diagnostics from config/analysis_plan.json . MDEs are approximate paired mean differences for quality_score at 80% power (sd =0.15 , α=0.05 ). Equivalence margins are ±0.05 . These values replace nominal 5,400-row arithmetic as the confirmatory sample-size story.
Condition
Extract
SQL
Summary
Compliance
Workflow
Overall
PydanticAI
100.0
100.0
100.0
100.0
100.0
100.0
LangGraph
100.0
100.0
100.0
100.0
100.0
100.0
DSPy
99.3
100.0
100.0
100.0
100.0
99.8
Plain SDK
33.3
33.3
64.0
35.3
33.3
38.8
Agno
33.3
33.3
63.3
35.3
34.0
38.8
CrewAI
32.0
33.3
64.0
35.3
0.0
32.8
Table 7: Confirmatory schema-validity rates (%) by implementation condition and task. Overall is row-weighted across the 5,400-row matrix.
Condition
Extract
SQL
Summary
Compliance
Workflow
Overall
PydanticAI
0.921
0.873
0.992
0.973
0.928
0.935
LangGraph
0.922
0.880
1.000
0.976
0.941
0.940
DSPy
0.890
0.760
1.000
0.981
0.944
0.911
Plain SDK
0.307
0.293
0.640
0.345
0.308
0.367
Agno
0.307
0.287
0.631
0.345
0.313
0.365
CrewAI
0.292
0.280
0.640
0.345
0.000
0.308
Table 8: Confirmatory mean automated quality by implementation condition and task. Quality metrics are task-specific (field accuracy, execution, grounding, etc.) under the shared scorers.
Task
Rows
Designs
Schema-valid
Flagged ( q<0.99 )
Mean q
compliance_qa
900
50
609
370
0.661
extraction
1800
100
1194
642
0.606
multi_step
900
50
551
175
0.572
sql_generation
900
50
600
94
0.562
summarization
900
50
737
9
0.817
Table 9: RQ2 contingency: schema-valid rows versus metric-flagged task discrepancies, with effective design counts (distinct sample_id).
Condition
Extract
SQL
Summary
Compliance
Workflow
PydanticAI
+0.017
+0.014
-0.122
+0.015
+0.058
LangGraph
+0.013
+0.015
-0.120
+0.013
+0.066
DSPy
+0.011
-0.076
-0.091
+0.047
+0.098
Plain SDK
-0.028
+0.002
+0.094
-0.045
+0.006
Agno
-0.027
-0.003
+0.087
-0.043
+0.014
CrewAI
+0.015
+0.047
+0.152
+0.014
-0.243
Table 10: Condition × task interaction residuals for mean quality after removing additive condition and task effects ( qft−qˉf−qˉt+qˉ ). Positive cells outperform the additive baseline; negative cells underperform.
Condition
Metric
PydanticAI
LangGraph
DSPy
Plain SDK
Agno
CrewAI
Zero-retry
schema
100.0
100.0
80.0
100.0
80.0
60.0
quality
0.925
0.934
0.741
0.926
0.730
0.555
provider_calls
1.00
1.00
1.00
1.00
1.00
1.00
After retry budget
schema
100.0
100.0
80.0
100.0
80.0
60.0
quality
0.923
0.934
0.741
0.926
0.739
0.555
provider_calls
1.00
1.00
1.60
1.00
1.60
2.20
Table 11: Updated zero-retry versus final-after-budget ablation (pilot matrix: 5 samples × 5 tasks, one replicate). Retry budget increases mean provider calls for weaker binders without closing the confirmatory-scale gap to strong binders.
Condition
Task
Schema%
Quality
Calls
Validators off
SQL
100.0
0.867
1.00
Compliance
100.0
0.966
1.00
Workflow
100.0
0.920
1.00
Validators on
SQL
100.0
0.867
1.00
Compliance
100.0
0.973
1.00
Workflow
100.0
0.933
1.00
Table 12: PydanticAI domain-validator ablation (15 instances × 3 replicates per cell). Enabling output validators yields small quality gains on compliance and workflow under an already ceiling schema-validity regime.
Condition
Task
Schema%
Quality
Calls
Typed-deps trace
Prompt-only context
Compliance
100.0
0.973
1.00
0%
Workflow
100.0
0.911
1.00
0%
Typed dependencies
Compliance
100.0
0.974
1.00
100%
Workflow
100.0
0.933
1.00
100%
Table 13: PydanticAI typed-dependency ablation (15 instances × 3 replicates). Typed deps are observable in traces; quality differences remain small relative to the confirmatory LCD gap versus weaker binders.
Task family
Business process
What “good” must mean operationally
Extraction
Accounts payable / intake automation
Fields are present and match the source document before posting.
SQL generation
Self-serve analytics
Query executes under least privilege and returns the intended grain.
Summarization
Management reporting
Claims are supported by the report; fluency is not enough.
Compliance QA
Policy / controls advisory
Answers cite the governing text and abstain when unsupported.
Workflow decision
Tier-1 support / case routing
Tool choice and human-review flags match operating procedure.
Table 14: Benchmark task families as business interfaces. Schema validity is an admission control for these processes, not a substitute for process controls.
Threat
Consequence for this paper
Mitigation in the confirmatory design
Construct-limited scores
Automated flags are not human-confirmed semantic error rates.
Deterministic scorers plus blinded audit packets; flags reported as candidates.
Implementation mismatch
The LCD matrix uses only a subset of each library’s advertised mechanisms.
Labeled feature-using ablations for RQ4; attribute results to concrete configurations.
Adapter fragility
CrewAI/Agno surfaces can change with package versions.
Pin versions in run provenance; retain SDK baseline.
Synthetic data
Clean templates may not represent document noise or production tools.
Retry/validator/typed-deps ablations do not exhaust RQ4.
Expand ablations before mechanism-level product claims.
Table 15: Primary validity threats, their effect on confirmatory claims, and mitigations.
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
Mechanism
Minimum active condition
Required evidence
Provider enforcement
Strict schema mode versus relaxed generation with the same final validator
Exact request mode, provider acceptance, parse result, and independent validity
Retry feedback
Common call budget with and without validation feedback
Attempt count, feedback text or hash, retry cause, final status, tokens, and latency
Typed dependencies/tools
Versioned resource passed through a typed boundary and an executed tool
Dependency version, validated arguments, authorization, tool result, and final disposition
Graph state
Multiple nodes, persisted state, and a review or recovery interrupt
State transitions, checkpoint/restart evidence, approval decision, and executed outcome
DSPy optimization
Frozen train/development/test split and declared optimizer
Optimizer configuration, development calls and cost, compiled program, and held-out results
Appendix
Table 16: Evidence required to attribute an outcome to a concrete mechanism rather than a framework label.
Condition
Files
LOC
Markers
Optional dependencies
PydanticAI
1
162
2
pydantic-ai
Plain SDK
1
146
7
none beyond shared dependencies
LangGraph
1
193
6
langgraph , langchain-openai
Agno
1
142
3
agno
DSPy
1
217
6
dspy
CrewAI
1
237
6
crewai
Appendix
Table 17: Static surface of the current implementation adapters. LOC and marker counts are descriptive artifact diagnostics, not maintainability ratings.
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.
Tool use has become central to modern LLM agents, yet interface design is rarely isolated as an experimental variable. This paper studies whether schema based tool contracts and structured validation diagnostics improve reliability under strict interaction budgets. We evaluate three conditions that preserve identical tool semantics and information content: free form documentation, JSON Schema specifications, and JSON Schema with structured diagnostics. We implement a deterministic software engineering sandbox with logs, metrics, configurations, and repository tasks, and evaluate a fully crossed pilot with one open local model, three seeds, three interface conditions, and four budgets. We report end task success, interface misuse, execution failures, semantic misuse, recovery behavior, and overhead. In this pilot, success remains zero across conditions, while schema conditions reduce interface misuse but not semantic misuse. The evidence supports a precise interpretation that interface formalization improves contract adherence, but semantic action quality and timeout sensitive tasks remain dominant bottlenecks under constrained local inference.
Structured output, where an LLM populates a predefined JSON schema, has become a default mechanism for data labeling and information extraction, but it also introduces a second instruction channel through schema descriptions. We tested whether classification-label definitions are better placed in the system prompt, user prompt, or schema description using a single-field classification task with nonce labels across ten model configurations from two vendors. Schema descriptions did not consistently outperform prompt-based placement; for GPT-4.1 and GPT-5.4 without reasoning, schema placement underperformed system prompts by 11-13 percentage points. Yet schemas are not inert metadata: when prompts and schemas conflicted, incorrect schema instructions caused accuracy drops of 5-45 points, with Claude Haiku 4.5 falling from 52.5% to 7%, indicating that schema instructions can override prompt instructions, and GPT-5.5 falling from 100% to 73%. Further, adding a required intermediate reasoning field before the label field improved schema-only accuracy by 15-24 points when headroom existed, exceeding system-prompt-only performance in every case tested. The effect held even for Claude Sonnet 4.6 at medium reasoning, where extended thinking alone did not produce a comparable gain. This suggests that schema design can affect how effectively models use information encoded in field descriptions. Overall, these results indicate that schema influence is model-dependent. In practice, the system prompt remains a safe default for definitions, but the bigger discipline is maintaining a single source of truth and preventing prompt/schema drift. More importantly, schema design itself may be a stronger lever than instruction placement. Practitioners should treat prompts and schemas as a unified instruction surface and empirically validate both placement and field design for their target model.