Two production models, 70 measured requests, four prompt styles and three hard cases. The JSON never broke — the interesting failures were in our rubric and in one field the text never contained.
Every agent tutorial tests structured output the same way: ask for JSON, parse it, celebrate. That test measures almost nothing, because the hard part of a pipeline is not getting braces back. It is trusting a field that the source text never contained.
We ran 70 requests against the two models our publishing pipeline already uses, in two phases. Phase one measured clean extraction under four prompt styles. Phase two measured the cases that break an agent: an ambiguous source, a long list where only one record matters, and a nested schema.
Method
- Models:
glm-5.3-flash(drafting) andglm-5.3(fact-check and editorial), through the same provider and key the production pipeline uses. - Temperature 0,
max_tokens300–400, one attempt per request (retries=1) — the measurement is first-attempt behaviour, not what survives a retry loop. - Four prompt styles in phase one: a plain instruction, a described schema, a worked example, and the plain instruction with distracting text around the payload.
- Ground truth: five short passages with the version, date and severity stated explicitly. Correctness means the JSON parsed, matched the schema and carried the right values.
- Phase two: five ambiguous passages (correct answer is
nullfor version and date), one passage listing eight releases where only record 5 was requested, and one nested schema with an array and a boolean.
The full transcripts, timings and token counts are in the artefacts named at the end.
Phase one: 40 of 40
Every one of the 40 requests returned parseable JSON, matched the schema and carried the correct values.
| Model | Style | JSON | Schema | Correct | p50 latency | |---|---|---|---|---|---| | glm-5.3-flash | plain | 5/5 | 5/5 | 5/5 | 1,499 ms | | glm-5.3-flash | schema | 5/5 | 5/5 | 5/5 | 1,364 ms | | glm-5.3-flash | example | 5/5 | 5/5 | 5/5 | 1,351 ms | | glm-5.3-flash | distracted | 5/5 | 5/5 | 5/5 | 1,708 ms | | glm-5.3 | plain | 5/5 | 5/5 | 5/5 | 5,277 ms | | glm-5.3 | schema | 5/5 | 5/5 | 5/5 | 7,181 ms | | glm-5.3 | example | 5/5 | 5/5 | 5/5 | 5,438 ms | | glm-5.3 | distracted | 5/5 | 5/5 | 5/5 | 3,681 ms |
Two things worth noting before the table is misread.
The structured-output mode did not help. Passing response_format: json_object (the "plain" and "schema" rows run with it) produced the same result as describing the schema in words. At this difficulty, provider-side JSON mode is a convenience, not a guarantee you can skip validation for.
The slower model is three to four times slower for no accuracy gain here. glm-5.3 has a median latency of 5.3 seconds against 1.4 seconds, and the same 20/20 score. On a 128-token extraction task the extra capability buys nothing; the case for it is judgement, not extraction.
The first measurement said 60%. The measurement was wrong.
The first run of phase one scored 24/40 correct — and 16 of those "failures" were our rubric's fault. Two bugs, both in the evaluator rather than the model:
- A sentinel compared as a string. Passages where the expected value was "absent" were written as the literal
"null"in the answer key. The model correctly returned JSONnull; the comparator turned the string"null"into"null"and JSON null intoNone, and scored a correct answer wrong. - An ambiguous passage in the "clean" set. One passage described a model family version and a parameter count in the same breath, and the answer key asserted one of them. The model picked the other, defensibly.
After fixing the comparator and replacing the ambiguous passage, the same models scored 40/40 — no change to prompt, temperature or model. This is the most useful result in the experiment: a reliability number is only as good as its rubric, and a bad rubric produces a confident, publishable, false conclusion.
Phase two: where it actually breaks
Ambiguous source: the model refuses to invent a version, then guesses a severity
Ten requests over five passages that state no version, no date and no explicit severity. In all ten, version and date came back null — no fabrication. But kind came back as "patch" or "major" in five of the ten, despite the text never using either word.
{"version": null, "date": null, "kind": "patch"}That is the failure a schema check cannot catch and a human reviewer would miss: a field that is grammatically valid, semantically unsupported, and plausible. If downstream logic branches on severity — "major release, write a longer piece" — it will branch on an invention.
The fix is not a better prompt. It is validating the value against the source text:
assert obj["kind"] is None or obj["kind"] in source_text.lower()Long list: no drift
One passage listed eight releases; only record 5 was requested. Ten of ten requests returned record 5 exactly. Record-selection over a short list was not a failure mode at all.
Nested schema: shape is free
Ten of ten returned the nested object with release, a populated highlights array and a boolean breaking set correctly. Recursion costs tokens, not accuracy.
What this changes in the pipeline
- Validation moved from "is it JSON" to "is it supported". The schema check stayed; a provenance check was added: a value that does not appear in the source is treated as unsupported.
- The expensive model is used only where judgement matters. Extraction runs on the fast model; the slow one is reserved for the fact-check and editorial verdict, where the 5-second latency is amortised over a whole article.
- The rubric is versioned with the experiment. A scoring function is code, and code has bugs; a reliability figure without its rubric next to it is a claim nobody can check.
Limitations
- Two models from one provider. These results say nothing about other vendors' JSON modes.
- Five passages per cell. Enough to catch a systematic error, not enough to estimate a rate to a percentage point — treat 5/5 as "no failure observed in five", not "100% reliable".
- Temperature 0 throughout. Sampling would raise diversity and, probably, failure rate.
- The nested and list cases were designed to be answerable. A genuinely ambiguous nested schema was not tested.
Sources
- OpenAI structured outputs guide
- JSON Schema specification
- llama.cpp grammar-constrained sampling (the local alternative)
Related
- Reliability patterns that keep retries from doubling the bill — what to do with a field you cannot trust.
- Running an AI agent on a 4-core VPS — the pipeline these models run in.
- API cost calculator — the latency difference above is also a cost difference at volume.
Comments
0 commentsSign in to join the discussion, or create an account.
No comments yet
Be the first to say something useful.