New here? Start this series at Day 7: Confidence is not evidence
- Day 7: Confidence is not evidence
- Day 8: Structured output turns model text into something software can trust
- Day 9: A capable model is not a product yet
- Day 10: Chatbot, workflow or agent: choose by how much autonomy the task can bear
- Day 11: RAG is an evidence design problem
- Day 12: Retrieval quality is decided before anyone searches
A beautifully written paragraph is a terrible API response.
Humans read prose. Software needs fields it can validate, route, store, and act on without guessing. The moment a model's output feeds another system rather than a person, free-form text stops being a feature and becomes a parsing problem you will maintain forever.
What a real output contract looks like
{
"answer": "The customer is eligible for escalation.",
"decision": "escalate",
"confidence": 0.82,
"evidence_ids": ["ticket-1842", "policy-returns-03"],
"missing_information": [],
"next_action": {
"type": "create_case",
"owner": "support_ops"
}
}JSON is incidental. What matters is that every field is something the system can check before anything irreversible happens. decision is a closed set, so an unexpected value is caught rather than acted on. missing_information gives the model a legitimate way to signal incompleteness instead of inventing a value to fill the gap. evidence_ids makes the claim traceable.
That last one matters more than it looks. A required schema field is harder to skip than an instruction, because an answer without it fails validation.
confidence needs more care. The model generates that number like any other text, so do not route on it until you have checked how well it tracks accuracy on labelled cases.
Design the shape before the prompt
The instinct is to write the prompt, look at the output, and then work out how to parse it. That order produces a schema shaped by whatever the model happened to emit.
Reverse it. Ask what downstream code needs to receive in order to act safely, define that, and write the prompt to satisfy it, so the schema acts as the requirement and the prompt as its implementation.
The fallback
Validation is only half a contract. The other half is what happens when validation fails, because it will, on some input, at some point.
Retry with the error attached? Fall back to a narrower model call? Route to a human? Fail the request cleanly? Pick one deliberately, because the default, partially-valid output flowing into a system that assumed it was fine, is worse than all of them. If you pick retry, cap it, or one malformed response becomes a latency spike and a larger bill.
Test this on a genuinely awkward request, not a clean one. Empty inputs, contradictory inputs, requests that fall outside scope. Those are what produce malformed output in production.
Validate at the boundary
Treat model output like input from a client you do not control. Validate it where it enters your system, and version the schema like any other API contract, because renaming or removing a field breaks every consumer that reads it. Then find the first downstream step that reads a model field and check what it does today when that field is missing or holds an unexpected value.
Terms in this piece
About this explainer
- Format
- Explainer
- Level
- Practitioner
- Read
- 2 min read
- Published
- May 30, 2026
- Disciplines
Short mental models: one idea, why it matters, what to do about it.
Discussion