DSPy OutputField constraints: checking the generated schema and returned score separately
Structured-output experiments should separate schema generation from post-response business-rule validation.
DSPy OutputField constraints: checking the generated schema and returned score separately
Writing score bounds in a response model does not establish that a derived schema sent to the provider retains them. A numeric response alone cannot prove adherence to every declared bound and step. Connect declaration, transmission, and actual response to locate the boundary where a constraint was lost. [1, 2, 3]
What the primary source establishes
A DSPy report describes Field keyword constraints disappearing from the derived structured-output model. Constraints expressed in annotations remain in the controls, and the author asks whether stripping is intentional for provider compatibility. [1]
The handover decision
Compare the declared and transmitted schema's bounds and multiple constraints. Inspect returned scores at a separate quality boundary before using them for decisions. Retain response_id, score, declared_min, declared_max, and quarter_step_residual so a well-formed numeric response does not become proof that every declared constraint was enforced. [1, 3]
A reference defined before the output
The illustrative score contract spans 0 to 1 in steps of 0.25. A score of 0.75 is within the range; 1.25 exceeds the upper bound. Check the multiple condition separately: being within range and lying on the permitted step grid are different requirements. [1, 3]
The scoped Truthound check
Truthound Core 3.3.2 provides BetweenValidator for scores in the approved range. Handle the multiple condition through a separate expression check using a properly prepared residual. The adapter decides which schema reaches the provider, and numerical range acceptance does not establish an answer's factual accuracy. [1, 2, 3]
Limits and alternative choices
Passing the range check does not establish LLM factual accuracy or the validity of the scoring construct. Use provider-supported constraints while retaining independent post-response validation. If the consuming task does not restrict the score, establish the basis for the declared upper bound first. [1, 3]
Application conditions
Retain declared and transmitted constraints and prepare returned score rows with independently specified bounds.
Alternatives
Use provider-supported constraints while retaining independent post-response validation.
Limitations
Passing the range check does not establish LLM factual accuracy or the validity of the scoring construct.
Evidence
- Event checked
- Subject checked
- Modified
