Home / Techniques that change the result
Structured outputs and guardrails
Forcing an exact schema on an output and checking that output before using it are two halves of the same reflex, one forces the form upstream, the other controls it downstream, and both matter more when the action that follows cannot be undone.
Structured outputs constrain Claude's answer to follow a precise schema, which guarantees a valid output that a downstream automated process can use. Two distinct mechanisms combine here: forcing the format of an answer according to a defined schema on one side, forcing the arguments of a tool call on the other. Both impose the form before the answer leaves, neither says anything about what happens once it has arrived.
The schema forces the form, not the content
Defining a schema amounts to drawing a template: these fields, these types, this order, nothing else. A first name field expects a string, an amount field expects a number, an answer that does not fit this template is rejected before it even reaches the programme that uses it.
schema attendu : { "nom": string, "quantite": number, "urgent": boolean }
sortie recue : { "nom": "gants de protection", "quantite": 12, "urgent": true }
The schema guarantees that the form above arrives every time, it does not guarantee that twelve is the right figure. The number of valid fields says nothing about the accuracy of any single one of them: that is exactly what a schema cannot see.
The guardrail checks what the schema cannot see
The second reflex takes over where the first stops: reading the output again once received, before passing it on to the next step. A guardrail can be a simple rule, this amount stays under a ceiling, this quantity stays positive, or a second pass that compares the output to the original request. Either way, the structured output passes through a second gate before acting, it does not just have to have the right shape.
This second gate matters more when the action that follows cannot be undone: sending a message, confirming an order, editing a shared file. A malformed output that just stays on screen gets fixed with a glance, a malformed output that triggers an action already carried out no longer gets fixed. This guardrail connects with the point already made in a green light proves nothing until it has been proven itself: a check that has never been caught out by a false output has not yet proven anything.
A free output against a forced output that is then reread
Il faudrait sans doute une douzaine de gants de protection, et c'est plutôt urgent je pense.
{ "nom": "gants de protection", "quantite": 12, "urgent": true } -> quantite > 0 : verifieA warehouse worker asks Claude to read a photographed paper order form and return the item name, the quantity and an urgency flag according to a schema set in advance. The answer obtained respects the three fields and their types, with the quantity twelve and the urgency flag set to true.
Write in one sentence what this situation establishes, and in one sentence what it does not establish.
What this establishes: The answer respects the requested schema, three fields present, each of the expected type, which makes it usable as is by a downstream programme.
What this does not establish: It does not establish that the quantity twelve actually matches what is written on the photographed order form, a respected schema does not guarantee accurate content.
The three most common miscalibrations
- Too broad Since the schema is respected, Claude correctly read every figure present on the photographed order form.
- Too narrow Only one order form having been processed, this answer says nothing about the schema itself.
- Beside the point This answer shows that the photograph of the order form was sharp enough to be sent to Claude.
- An output schema guarantees the form of an answer, never the accuracy of its content, the two are checked separately.
- The guardrail steps in after the answer, not before: it rereads what has just arrived rather than stopping a bad form from leaving.
- An action that cannot be undone deserves a stricter guardrail than an output simply displayed on screen.
- Forcing the form and checking the content are two distinct steps in the same flow, not two different ways of doing the same thing.
Choose a task where you regularly ask Claude for a list or an amount, write down the three exact fields the answer must contain, and add a rule sentence you will apply yourself before using that answer.
These points depend on an interface or a rule that may have changed since this was written. Check them on your own screen before relying on them.
- The list of models that support structured outputs changes over time: open the structured outputs page on your screen and check that the model you use appears on it before building a schema on top of it.
Every datable claim in this lesson links here to the public text behind it. A source that does not open proves nothing.
- Anthropic, Structured outputs consultée le 2026-09-02