What does strict mode on a tool schema guarantee, and what does it cost?
answer
- shape guaranteed, meaning not
- constrained decoding, not post-validation
- only a subset of JSON Schema compiles
- optional becomes nullable-and-required
- no legal way to say "unknown" forces invention
basics
~20 sStrict or structured-output modes constrain decoding so emitted arguments are guaranteed to match the declared schema — right keys, right types, no invented extras. They guarantee shape only, not truth, and they buy that with a restricted JSON Schema subset and some first-use latency.
solid answer
~50 sStrict mode moves the schema from advice to enforcement. Instead of hoping the model emits conforming JSON, the runtime constrains sampling to tokens that can still complete a valid instance, so a call with an extra `notes2` key or a number where a string was declared becomes impossible rather than merely unlikely. That removes a whole class of parse-and-retry code. The costs are real: providers accept only a subset of JSON Schema in strict mode, often demanding `additionalProperties: false` and every property listed in `required` — with optionality expressed as a nullable type rather than omission — and there is usually a one-off compilation cost the first time a given schema is used. And the guarantee stops at shape. A structurally perfect call can still name a policy that does not exist, so handler-side validation and authorisation do not go away. As of mid-2026 the exact supported subset differs by provider and moves, so verify rather than assume.
code
json · 20 lines{
"name": "file_claim",
"strict": true,
"parameters": {
"type": "object",
"additionalProperties": false,
"properties": {
"policy_number": {"type": "string"},
"claim_type": {
"type": "string",
"enum": ["auto_collision", "auto_theft", "property_fire", "property_water", "property_theft", "liability"]
},
"adjuster_notes": {
"type": ["string", "null"],
"description": "Notes stated by the caller, or null if none were volunteered."
}
},
"required": ["policy_number", "claim_type", "adjuster_notes"]
}
}go deeper
Know that strict or structured-output mode makes tool arguments conform to the declared schema, so keys, types and enum values are guaranteed rather than hoped for.
Explain that it works by constraining decoding rather than validating afterwards, and describe the structural demands — closed objects, everything required, optionality expressed as nullable.
Draw the shape-versus-semantics line clearly: it eliminates parse-and-retry code but never replaces authorisation or referential checks, and an over-tight schema can force invention where declining was correct.
Own the policy of where enforcement lives — which tools must run strict, how schemas stay inside the supported subset as providers change it, and how you keep the same tool definition usable across providers with different strict rules.
## What the mode is Without strict mode, a tool's parameter schema is strong guidance. The model has read it, usually honours it, and occasionally does not — a missing required key, a number rendered as a string, an extra field it thought would be helpful. Your code parses, validates, and either repairs or hands the failure back. Strict mode, sold under names like strict schemas or structured outputs, changes the mechanism. The schema is compiled into a constraint over the token stream, and at each decoding step only tokens that could still lead to a valid instance are permitted. The result is not a validated output; it is an output that could not have been invalid. Free-form generation is unaffected — only the argument JSON is constrained. ## What it guarantees - **Key set.** Only declared properties can appear. With `additionalProperties: false`, an invented `notes2` alongside a declared `notes` is unreachable, not just improbable. - **Presence.** Every property the schema demands is emitted. - **Types.** A string field cannot come back as a bare number, an array cannot arrive as a comma-joined string. - **Closed vocabularies.** An `enum` becomes a hard restriction, so out-of-set category values stop appearing. - **Well-formedness.** The JSON parses, always — no truncated braces from an unlucky sample. Collectively that removes the retry-on-parse-failure branch that otherwise sits around every tool call, and removes the normalisation layer that maps eight spellings of a category to one. ## What it does not guarantee Shape is not meaning. Strict mode has no opinion on whether: - the value is true — a well-formed policy number can belong to nobody, or to a different customer; - the value came from the conversation rather than the model's imagination — a required string is filled either way; - the *right tool* was chosen — constraint applies to arguments, not selection; - cross-field logic holds — a claim dated after today, or a location inconsistent with the stated policy, passes a schema happily. So the handler still validates. Strict mode changes what your validation is for: it stops being a parser and becomes a semantics and authorisation check. Candidates who say strict mode lets them drop server-side validation are describing a security bug. ## What it costs **A restricted schema vocabulary.** Constrained decoding needs a schema it can compile, so providers accept a subset of JSON Schema. Support for validation keywords — string patterns, numeric bounds, format assertions, and the more exotic composition keywords — varies and has changed repeatedly. Anything unsupported has to move out of the schema and into your handler, or into the field's description as a natural-language instruction. **Structural demands.** A common requirement is `additionalProperties: false` on every object, plus every declared property listed in `required`. That collides with genuinely optional fields, and the standard workaround is to declare them as a nullable union type — the key is always present, and the model signals absence with an explicit null. Your handler then treats null and absent identically. It is workable, but it means "optional" is expressed differently under strict mode than without it, and a schema written for one will not simply drop into the other. **Latency and caching.** Compiling a schema into a decoding constraint is not free; the first use of a novel schema can carry noticeable extra latency, with subsequent uses served from a cache. This is invisible in steady state and very visible if you generate schemas dynamically per request, which is a good reason not to. **A small behavioural cost.** Constraining the token distribution can nudge output quality on the margin, and an over-tight schema can force the model to fabricate rather than decline — if there is no legal way to express "I don't know", the constraint guarantees it emits something. The mitigation is to design the schema so uncertainty is expressible: a nullable field, an `unknown` enum member, or a separate path for asking the user. ## When to use it Turn it on by default for tools whose arguments flow into systems where a malformed call is expensive, and for anything with a categorical field you were previously normalising by hand. It matters most where the schema is deep or the enum set large, since those are where unconstrained models drift. Relax it when you need schema features the strict subset does not accept and cannot express another way, or when the tool's arguments are tolerant free text where the retry cost is trivially low. Reflecting practice as of mid-2026: the supported subsets differ across providers and continue to move, so treat any specific list of accepted keywords as something to verify against current provider documentation rather than something to memorise.
- With strict mode on, can you drop server-side validation of tool arguments?No, and saying yes is a security answer, not an efficiency one. Strict mode guarantees the arguments parse and match the declared shape; it says nothing about whether the policy exists, belongs to this caller, or is in a state that permits the action. Authorisation and referential checks must stay in the handler, which is now free to assume well-formed input and focus on semantics.
- How do you express a genuinely optional parameter when strict mode requires every property in required?Declare it as a nullable union type and keep it in the required list, so the key is always emitted and absence is signalled by an explicit null. The handler treats null and absent as the same thing. The field's description should say when to send null, otherwise the model tends to fill it rather than admit it has nothing.
- Why can an over-tight schema increase fabrication rather than reduce it?Because constrained decoding removes the option of not answering. If every field must carry a value and no field can express uncertainty, the only reachable outputs are ones with values in them, so the model produces a plausible value instead of declining. Designing an escape hatch — a nullable field, an unknown enum member, or a separate clarification path — restores the honest option.
saying these in an interview costs you the question
- Claims strict mode makes server-side validation unnecessary
- Thinks it validates values, not just structure
- Assumes the full JSON Schema vocabulary is supported
- Expects omission to work for optional fields under strict mode
- Generates a new schema per request and blames latency on the model