Skip to content

Schemas that refuse to lie: cheatsheet

ModeWhat it guaranteesUse for
auto (default)Nothing about shape; model may answer in proseOpen-ended agent work
anySome provided tool is called; some schema honoredModel routes among several extractors
tool (specific, by name)That tool’s schema on every runExtraction pipelines

Not on the ladder: a fourth mode, none, forbids tool calls entirely; no role in extraction pipelines.

Plus strict mode: strict: true on the tool definition constrains token sampling so arguments cannot break the schema. Whole-response equivalent: the structured outputs feature (output_config).

Spine: a prompt format instruction is a request; a schema is a guarantee.

PatternEffectVerdict
Required, non-nullableAbsent data forces a plausible inventionFabrication engine
Optional (not in required)Model may silently skip; absent vs skipped is ambiguousAvoid
Required + nullableModel must answer; null means “looked, not there”Use this

Field description carries weight: “Use null if the document shows none. Never guess.”

WithoutWith
Closed list force-fits reality into nearest legal value, silentlyCatch-all value (“other”) + nullable detail string preserving what was seen
Misclassification is invisibleCatch-all frequency is a sensor on your inputs
Guaranteed by schema (syntax)Never guaranteed (semantics)
Parseable JSON, right fieldsValues actually correct
Correct typesSums match across fields
Legal enum valuesRight value in the right field

Edge cases even for shape: a safety refusal or a hit token limit can produce off-schema output. Check, then trust.

Semantic validators (cheap code, downstream)

Section titled “Semantic validators (cheap code, downstream)”
CheckExample
Cross-field arithmeticLine items sum to total
Range sanityInvoice date within a sane window
Conditional consistencyEnum is “other” implies detail is filled; decision null implies owner null
Validator fires because…Is the answer in the source?Action
Sum mismatch, transposed digits, swapped fieldsYes, misreadRetry once with the specific error
Malformed or inconsistent pair of fieldsYes, mismappedRetry once with the specific error
Nullable field came back nullNoAccept; null is the system working
Two retries already spentEitherEscalate to a human queue

Retry message rule: name the exact failure and point back at the source. “Validation failed” gives the model nothing.

PitfallCorrection
Required field the source might lackAudit required list against your ugliest documents
Enum with no escape hatchCatch-all value + detail string
Trusting syntax as truthSemantic validators stay in code
Retrying against absenceFabrication pressure with a delay timer; accept the null
Optional as honestySilent ambiguity; use required + nullable
LineMeaning
The lie was designed inFabrication traces to the schema, not the model’s mood
A required field is a bet the information always existsLose the bet once, get fiction
Valid is not the same as trueSchemas check shape, not content
Never negotiate with realityRetries fix misreadings, not absence