5 Undocumented Rules for Gemini Structured Output, Measured in Production A developer reports undocumented behaviors in Gemini's structured output schema, discovered through production measurements on a document extraction pipeline. The required array controls emission order, which affects correctness, and reordering it fixed a role classification error in 9 of 9 cases, up from 5 of 9. The findings include that enum descriptions are not enforced and that a PROVIDER_EXHAUSTED error after a prompt change indicates a broken schema. We run a document extraction pipeline on Gemini with a native responseSchema attached, not a "please reply with JSON" instruction in the prompt text. Over two months, three separate production problems traced back to behaviours of that schema that are not in Google's documentation. These are the rules we ship with now, and the measurement behind each one. The domain is anonymized no client, no industry, role codes renamed . Every number, date, model name and error string is real. required array identity, then evidence, then derived. It controls emission order, and emission order controls correctness. enum arrays are enforced. Values listed in a description are not constrained at all. PROVIDER EXHAUSTED right after a prompt change means your schema is broken, not that Google is busy. required identity, evidence, derived Gemini emits every required property first, in exactly the order the required array lists them, then the optional ones. The declaration order inside properties is ignored for the required set. This is empirical. It is not in Google's docs. We measured it on gemini-3-flash-preview twice, with opposite orders, reading the raw response text: | schema | position of role code in required | position in emitted JSON | |---|---|---| | v18 | 3rd | 3rd | | v19 | 14th last | 14th | In v18 that field was 12th in properties and 3rd in required . It came out 3rd. properties is not the lever. propertyOrdering is the documented knob, but if you do not set it we do not, anywhere , the required order is what governs. A model writing JSON does one forward pass. Whatever it has already emitted is in context. Whatever it has not is not. And an emitted token cannot be revised when a later field contradicts it. So a field emitted early is decided with almost no self-generated evidence, and a field emitted late is decided with everything above it visible. v18 put role code third in required , after only first name and last name . Its instruction was a priority ladder: work history entry Nine CVs, all advertising the same role. Four came back with L3-OPS , a role from a different department. All four were internally self-contradictory: { "role code": "L3-OPS", "department": "Technical", "work history": { "title": "L3-TECH", "...": "..." } } Both codes are valid members of the 143-value enum, so nothing rejected the output. department , which agreed with the correct reading in all four cases, was emitted 11th, long after the wrong token was committed. The consistency check that would have caught the error was generated downstream of the error. Ruled out first: environment drift schemas byte-identical , downstream mapping the wrong code was already in the raw provider response , a missing enum value the correct code was present, and used correctly elsewhere in the same responses , and ambiguous source documents zero matches for any operations wording, 11 to 20 matches for technical wording per document . Reorder required . Nothing else. No type change, no enum change, no shape change. v18: first name, last name, role code, contacts, nationalities, date of birth, work history, certifications, documents, education, languages, address, home airport, department v19: first name, last name, date of birth, nationalities, contacts, work history, certifications, education, documents, languages, address, home airport, department, role code Result: 9 of 9 correct, up from 5 of 9. Emitted position of role code moved 3 to 14, exactly as predicted. | class | meaning | position | |---|---|---| | identity | copied off the document, no reasoning first name , date of birth | first | | evidence | the substantive extracted content work history , certifications | middle | | derived | a judgement about the evidence role code , department , any score, total or summary | last | Three things that come with the reorder: Descriptions must not forward-reference. Once department moved ahead of role code , its old text "classify from the stated role code " became the same bug in miniature. After any reorder, re-read every description for references to fields that now come later. Tell the model the evidence is already there. Reordering alone is silent. v19's priority 2 became: "You have ALREADY emitted the work history array above. Read the title of its first entry and use it." Check for over-anchoring. The goal is grounding, not echoing. Two candidates whose most recent entry was one level below the applied-for role still correctly emitted the applied-for level, because priority 1 legitimately outranks priority 2. If every derived value suddenly equals evidence 0 , you have over-corrected. And the trap: required is a set to a JSON Schema validator. Reordering it is semantically inert, so a formatter that sorts the array, or a tool that round trips the JSON, silently reverts the behaviour with a diff that looks like whitespace and passes every test. Say so in the file. Do not respond to a wrong derived field by adding more prose first. v18 already carried four bullets of correct guidance for that field and was still wrong about 44% of the time. The instruction was not being disobeyed. It was being evaluated at a token position where its input did not exist. Gemini rejects a schema above an undocumented ceiling on the total enum-value count across the whole schema. Google publishes no number, only that "very large or deeply nested schemas may be rejected". | total enum values | result | when | |---|---|---| | 467 | accepted | v9, production | | 610 | accepted, months of clean runs | v10-revised through v14 | 740 | rejected | v15, 2026-08-17 | | 754 | rejected, reverted | v10-initial, 2026-07-13 | The boundary is in 610, 740 . We never bisected it. Three checkpoints were tried with the 740 schema, one preview and two GA releases: | model | outcome | |---|---| gemini-3-flash-preview | 400 invalid argument | gemini-3.5-flash | 400 invalid argument | gemini-3.6-flash | 400 invalid argument | Identical rejection across releases spanning months. This is a property of the constrained-decoding compiler, not of a checkpoint, so waiting for a newer model is not a mitigation. You cannot deduplicate your way under the limit. Gemini's subset has no $ref and no $defs see Rule 4 , so every repeated list is paid for in full. A 145-value list used in three places costs 435, not 145. Practical consequences: description instead. Descriptions cost nothing against the budget. Just know they are not enforced either Rule 3 .A rough counter is worth having in CI: // Sums every enum array in a schema, nulls included. function countEnums node { if Array.isArray node return node.reduce n, v = n + countEnums v , 0 ; if node && typeof node === 'object' { return Object.entries node .reduce n, k, v = n + k === 'enum' && Array.isArray v ? v.length : countEnums v , 0 ; } return 0; } responseSchema guarantees JSON shape and types. It does not guarantee values, with one exception. | how you express it | enforced? | |---|---| "enum": "L3-TECH", "L3-OPS" | yes, by constrained decoding | allowed values listed in description | no, purely advisory | maxLength | no | | array uniqueness | no | In July, a schema change meant constrained decoding stopped being applied for five days. Nothing failed, nothing turned red, and 75 values that do not exist in the vocabulary reached production in a field the rest of the system indexes on. So: If the same prompt may run on more than one provider, store the schema in the more restrictive format. Gemini's subset is the floor. | feature | OpenAI | Gemini | |---|---|---| $ref / $defs | supported | not supported, inline everything | $schema , $id | supported | not supported, strip | oneOf | supported | not supported, single type + nullable | "string", "null" | supported | not supported, use nullable | exclusiveMinimum | supported | not supported, use minimum | pattern | supported | stripped | format: "uri" | supported | stripped | nullable | not used | required for nullable fields | | max nesting | no limit | 5 levels | | property ordering | not enforced | required order drives emission | Rejected: { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "role code": { "$ref": " /$defs/RoleCode" }, "start year": { "type": "integer", "exclusiveMinimum": 1900 }, "email": { "type": "string", "null" }, "website": { "type": "string", "format": "uri" }, "ref": { "type": "string", "pattern": "^ A-Z {2}-\\d{4}$" } } } Accepted: { "type": "object", "properties": { "start year": { "type": "integer", "minimum": 1901 }, "email": { "type": "string", "nullable": true }, "website": { "type": "string" }, "ref": { "type": "string", "description": "Two uppercase letters, hyphen, four digits" }, "role code": { "type": "string", "enum": "L3-TECH", "L3-OPS" } }, "required": "start year", "email", "website", "ref", "role code" } Note role code is last in required , per Rule 1. A malformed schema does not degrade politely. On 2026-08-27 a single "type": "string", "null" union in one prompt failed every execution of it until the union was removed. This is the one that costs the most hours, because the label sends you to the wrong system. What the provider actually returns: 400 . Request contains an invalid argument. No field pointer, no property name, no mention of size or enums. Deterministic on every retry, every key and every service tier. What the operator sees by the time it surfaces: processing error PROVIDER EXHAUSTED: Provider capacity unavailable error reason code PROVIDER EXHAUSTED model empty The chain is 400, then an API error, then the key circuit opens, then the retry ladder exhausts, then the last event gets reported instead of the first. It reads as a transient capacity shed. It is a permanent schema defect. Triage table: | symptom | actual meaning | |---|---| PROVIDER EXHAUSTED with an empty model field, starting right after a prompt change | schema defect, not capacity | | the same failure on both STANDARD and FLEX tiers | not a tier or quota problem | | identical failure across model checkpoints | constrained-decoding compiler, not the model | | valid JSON with out-of-vocabulary values | constrained decoding was not applied at all | The real error survives only in a WARN line, on whichever replica ran the worker, which is usually not the replica that logged the submission. Grep all of them: for P in $ kubectl -n