OpenAI rejects your schema. Anthropic returns a string and calls it an object. Gemini says no to unions but yes to everything else. Carrick's new benchmark proves that "HTTP 200" does not mean "valid payload."


By Taygotech


If your agent pipeline trusts a 200 status code as proof that a tool-call payload is correct, you are shipping broken JSON to your downstream logic. The structured outputs APIs from OpenAI, Anthropic, and Google Gemini each fail in different silent ways. A new open-source benchmark from Carrick isolates exactly how, and the results are not flattering for any of the three providers.

David Moores, who built the code-analysis tool Carrick, published the benchmark after his own post-LLM pipeline needed a four-stage fallback parser. Direct parse, strip markdown fences, scan for array bounds inside garbage text, regex cleanup. If all four fail, drop the payload and move on. If structured outputs worked as advertised, that pipeline would be a single serdejson::fromstr(response). It is not.

The benchmark tests eight synthetic schemas against six models. Each schema isolates one structural stressor. A flat baseline. Three-level and seven-level nested objects. A long enum. A oneOf tagged union. Nullable fields with format constraints. A twenty-item array. A closed object with additionalProperties: false. Every response is validated against the original schema with two independent validators, ajv and hyperjump. A response only counts as strict adherence when both agree.

Here is how the providers actually behave.


Anthropic: Accepts Everything, Then Silently Corrupts Deep Nesting

Anthropic's tool-use API is the most permissive gatekeeper of the three. It accepts almost any standard JSON schema. On seven of the eight bench schemas, both Claude Sonnet 4.6 and Claude Opus 4.7 produce strict-conforming output on every single run.

The failure mode is concentrated on one schema. A seven-level nested object chain.

On that schema at twenty runs per model:

  • Claude Sonnet 4.6: 20 of 20 runs silent-failed. Strict adherence: 0%.
  • Claude Opus 4.7: 7 of 20 runs silent-failed. Strict adherence: 65%.

The model does not return an error. It does not return malformed JSON. It returns a perfectly parseable JSON object where the root field level1 is supposed to be an object, but the model hands back a single JSON-encoded string containing the entire nested structure.

Here is one of the Opus failures verbatim:

{"level1":"{\"name\":\"system\",\"child\":{\"name\":\"ingest_pipeline\",\"child\":{\"name\":\"batch_24a17\",\"child\":{\"name\":\"parse_stage\",\"child\":{\"name\":\"error_handling\",\"child\":{\"name\":\"dlq_promotion\",\"leaf\":{\"value\":\"2 rows failed JSON parsing and were promoted to dlq.ingest.parse-errors; weekly cleanup later inspected 412 items, removed 312, returned 100 for reprocessing\",\"kind\":\"outcome_summary\",\"count\":2}}}}}}}}"}

The schema says level1 is type: object. The model returns type: string. The JSON parser succeeds. The schema validator fails. Only an explicit validator catches the drift.

This is the most dangerous failure mode in the entire benchmark for three reasons.

The transport layer says success. The API returns HTTP 200 with no error field and no refusal signal. Your retry logic never fires.

The SDK does not validate. The Anthropic client passes tooluse.input back to your application without checking whether it matches the inputschema you sent.

The output parses cleanly. JSON.parse(response) returns { level1: "{\"name\": ..." }. Your downstream code receives a string and treats it like an object, or crashes when it tries to access .child on a string.

The mechanism is consistent across all twenty-seven silent failures in the dataset. Twenty from Sonnet, seven from Opus. The model wraps the entire nested payload in a single string value. The only variance is where the string boundary sits.


OpenAI: Enforces Perfection by Rejecting Most Schemas Before They Reach the Model

OpenAI's strict: true mode is the exact mirror of Anthropic. Where it accepts a schema, it produces strict-conforming output every time. Where the schema does not fit OpenAI's narrow dialect, the request dies before it ever sees a model.

Of the eight bench schemas, only two pass OpenAI's strict-mode rules. The baseline flat schema, which the author deliberately shaped to be strict-compliant, and the closed object schema. The other six are rejected before the call is sent.

OpenAI strict mode demands three things:

  • Every object must declare additionalProperties: false.
  • Every property must appear in the required array.
  • Type arrays like ["string", "null"] and oneOf unions are unsupported.

If you pull a schema from an OpenAPI spec or a package.json, it will probably fail. A representative rejection for the seven-level nested schema reads like this:

OpenAI strict mode violations:
 $: object missing additionalProperties: false;
 $.level1: object missing additionalProperties: false;
 $.level1.child: object missing additionalProperties: false

The rejection rate is identical between gpt-5.4-mini and gpt-5.5. The check runs server-side at the schema-submission layer before any model is invoked. Flagship intelligence does not change the outcome.

Your options are to rewrite every schema to the strict dialect, or disable strict mode and inherit Anthropic's silent-failure problem. OpenAI gives you a choice between upfront rejection and downstream corruption.


Gemini: The Narrow Gate That Never Lets a Bad Payload Through

Gemini sits in the middle. It rejects modern JSON Schema features that OpenAI strict also bans, like oneOf and type arrays. But it accepts the looser shapes that OpenAI strict refuses.

On the six of eight bench schemas that clear Gemini's pre-flight, both Gemini Pro 3.1 and Gemini Flash 3.5 maintain 100% strict adherence. The two rejected schemas are the oneOf union and the nullable string with format: date-time. Gemini surfaces the rejection at submission time with a clear error naming the unsupported feature.

Notably, Gemini handled the same seven-level deeply nested schema that destroyed Anthropic. 100% strict adherence on every run. Where Gemini accepts a schema, it conforms.

The trade-off is explicit. Gemini will not run your fancy union schema. But it will not silently hand you a string and call it an object either.


The Scoreboard: 0%, 25%, and 100%

Here is the condensed picture.

  • Anthropic Sonnet 4.6: 0% strict adherence on deep nesting. Accepts every schema, silently corrupts one.
  • Anthropic Opus 4.7: 65% strict adherence on deep nesting. Better, but still shipping broken payloads one-third of the time on complex schemas.
  • OpenAI strict mode: 100% adherence on what it accepts, but rejects 6 of 8 standard schemas.
  • Gemini: 100% adherence on every accepted schema, rejects 2 of 8.

The gap between Anthropic's 0% and Gemini's 100% on the same seven-level nesting schema is not a rounding error. It is a production incident waiting to happen.


What This Means for Production Agents

The problem is not that structured outputs are broken. The problem is that they are broken in ways your monitoring will not catch.

Most agent pipelines have a simple success model. Send the request. Get 200. Parse the JSON. Pass it to the next step. If parsing succeeds, the payload is assumed valid. That assumption is wrong for Anthropic deep nesting. It is wrong for any provider when semantic drift occurs. And it is wrong for OpenAI when you accidentally disable strict mode and the model returns a structurally valid but schema-violating object.

The Carrick benchmark cost roughly $8 in API credits and about an hour of wall time to run. The full run is 4,320 calls. A cheap pilot of 45 calls costs about $1 and is enough to see if your specific schema triggers divergence. The repo is open-source at daveymoores/carrick-llm-structured-bench.


Defensive Patterns That Actually Work

The provider feature called "structured output" cannot be trusted as an application boundary. You need explicit guardrails.

Run an independent validation step. An HTTP 200 from the provider means nothing. Validate every response payload against your schema using ajv, hyperjump, Pydantic, or Zod before passing the data to your application logic. The validator is your contract, not the API response.

Redefine success. Treat a parse error, a schema violation, and a refusal as the same failure mode. Trigger the same retry or fallback logic for all of them. Do not special-case the 200 that contains a string instead of an object.

Flatten Anthropic schemas. Deep nesting triggers silent corruption in Claude, including at the flagship tier. Flatten structures into top-level arrays of sibling objects wherever possible. If a schema exceeds three or four levels of depth, refactor it.

Compile schemas to the OpenAI dialect. If you target OpenAI strict mode, author schemas from the start with additionalProperties: false at every sub-level and no optional fields. Do not retrofit existing schemas.

Strip unions for Gemini. Avoid oneOf and ["string", "null"]. Use anyOf if you need unions, and rely on a single nullable type constraint.

Inspect finishreason. If the provider returns finishreason: "length", the payload is truncated. Do not parse it. Retry with a higher token budget or decompose the task.

Validate-retry, but not blindly. Libraries like Instructor automate the retry loop by embedding the validation error back into the prompt. This often fixes the failure in one additional attempt. But a 100% retry rate masks a systematic schema problem. Track retry rate as a primary quality metric. Baseline should be 0.5% to 2%. A spike to 5% or higher means your schema or your model has drifted.


The Bigger Picture

The structured outputs era began with a promise. Pass a JSON schema, get back JSON that conforms to it. That promise is only partially kept, and each provider keeps a different part.

OpenAI keeps the schema part by refusing to run schemas it cannot guarantee. Anthropic keeps the runtime part by accepting every schema but silently corrupting complex ones. Gemini keeps the correctness part by rejecting a narrow set of features and conforming perfectly on everything else.

No provider gives you all three. Accept any schema, guarantee conformance, and do it silently. Pick two.

For production agents, the lesson is simple. The API is not your validator. The 200 status is not your contract. You need client-side validation, provider-aware schema design, and monitoring that treats structural correctness as a runtime invariant, not an assumed default.

The Carrick benchmark proves the gap exists. The gap is large. And most agent pipelines are flying straight through it.


Sources:

  • Moores, David. "Benchmarking LLM Structured Outputs." Carrick Tools, May 2026. DEV.to cross-post and original writeup.
  • daveymoores/carrick-llm-structured-bench. Open-source benchmark repository. MIT License.
  • Tian, Pan. "Structured Outputs Are Not a Solved Problem: JSON Mode Failure Modes in Production." tianpan.co, April 2026.
  • "[BUG] Model serializes arrays as JSON strings in StructuredOutput." Anthropic Claude Agent SDK Python, GitHub Issue #510.
  • "Schema additionalProperties must be false when strict is true." OpenAI Developer Community, 2025.