I fuzzed four LLM structured-output engines without loading a model. The hard part was stopping my fuzzer from lying
The idea
Structured-output engines (llguidance, outlines-core, XGrammar, llama.cpp's grammar sampler) turn a JSON Schema into a token mask that is applied at every decoding step. If the mask blocks a token that leads to valid JSON, the model can never write a valid document. If it allows a token that cannot lead to valid JSON, the model writes an invalid one.
I wanted to test that mask directly, for $0, without any model weights. The tool is sieve-df, written in Rust:
Code, data and every result: github.com/Flotrpy/sieve-df
How it works
It only needs a tokenizer.json (I used Qwen2.5's). It does random walks over each engine's mask, weighted toward the tokens where mask bugs cluster: ": , "},{", leading-space tokens, escapes.
At every step it checks:
- Contradiction: the mask allows a token, but the engine rejects it when it is fed.
- Dead end: an allowed token leads to a state with no allowed tokens and no way to finish.
- Invalid output: the engine allows end-of-text, but
jsonschema-rssays the document violates the schema. - Disagreement: two engines differ on one token. To decide who is right, it tries to finish the output and validates the result. A valid finish exists, so the engine that blocked the token is too strict. No valid finish could be produced, so the engine that allowed it is too loose.
- Crash and hang, each isolated so one bad schema doesn't end the run.
Every bug is then shrunk to a minimal schema plus token path and written as a markdown issue draft.
llguidance and outlines-core are linked as Rust crates. XGrammar and llama.cpp run through a small Python subprocess that speaks JSON lines.
First results
One run: 84 schemas (bundled examples, MCP tool schemas and mutated variants), 1,175 random walks, a 300-token synthetic vocabulary.
| Engine | Walks | Raw findings | Invalid outputs | Too strict | Too loose |
|---|---|---|---|---|---|
| llguidance 1.9.1 | 360 | 527 | 0 | 527 | 0 |
| outlines-core 0.2.14 | 395 | 877 | 154 | 551 | 171 |
| XGrammar 0.2.9 | 420 | 208 | 40 | 108 | 60 |
Read those as raw findings, not bugs. The same root cause shows up again and again, which is why the shrinker matters: 1,612 raw findings collapsed into 79 distinct minimized bugs (llguidance 7, outlines-core 37, XGrammar 35).
What it found
Five of these are pinned by tests in the repo, so they fail loudly when an upstream release fixes them:
| Engine | Finding | Minimal schema |
|---|---|---|
| outlines-core | Quotes in property names are not escaped: the mask accepts {"a"b":true}, which isn't JSON |
{"properties":{"a\"b":{"type":"boolean"}},"required":["a\"b"]} |
| outlines-core | minimum is ignored (-5 is accepted) |
{"type":"integer","minimum":0} |
| outlines-core | Compilation blows up | {"type":"object"} |
| outlines-core | pattern anchors stay in the regex, so the schema is rejected | {"type":"string","pattern":"^https?://"} |
| llguidance | A raw DEL character inside a string is blocked, although it is legal JSON | {"type":"string"} |
Other candidates (XGrammar blocking 0 right after -, partial UTF-8 bytes in strings, some \u hex digits in llguidance) still need minimal reproductions before I'd call them bugs.
Where my fuzzer lied to me
This was most of the work. Each of these produced hundreds of confident, wrong findings:
- Floats the reference can't hold.
1e999999is valid JSON, but the Rust JSON parser can't represent it, so valid output looked invalid. Now classified as "indeterminate". - A default I didn't know about. XGrammar's
strict_modedefaults to forbidding additional properties, which looked like thousands of "too strict" findings. Engine configuration is part of the comparison; I now run it withstrict_mode=Falseto follow the spec. - Policy, not bugs. Engines legitimately differ on how much insignificant whitespace they allow. A tiny JSON lexer now tells whether a token puts whitespace outside a string, and those disputes are skipped.
- "Too loose" from giving up. My completion search would fail to close deeply nested documents and then blame the engine. It now searches much harder (up to 32 attempts of 640 steps) before concluding anything. It is still a heuristic: "no valid finish found" is not a proof.
- My own hang handling. outlines-core builds its regex DFA without a limit, so
{"type":"object"}explodes. I ran compilation on a thread with a timeout, but threads can't be cancelled, and the abandoned ones ate CPU and, in one run, about 68% of 16 GB of memory. The fix was to check the DFA size up front against a 64 MiB budget and cap the number of stuck threads.
What I'd tell myself at the start
- The judge matters more than the fuzzer. Validating a finished document with
jsonschema-rsis a sound oracle; most of my early noise came from places where I had no sound judge. - Separate bugs from policy before you count anything.
- Bound everything that can hang. In Rust you can't kill a thread, so detect the blow-up before it starts.
- Shrink before you read. Raw counts are meaningless; minimal cases are readable.
- Pin every bug with a test that fails when upstream fixes it.
Honest limits
- The walks use a 300-token synthetic vocabulary. Qwen2.5's 151,665-token vocabulary was only used for the latency numbers, so tokenization-specific bugs on a real vocabulary are mostly untested.
- One run, fixed seed, no error bars. Raw counts are not bug counts.
- "Too loose" verdicts rest on a random search. Treat them as leads.
- The llama.cpp engine works but wasn't part of the main run: its masks take about 17 ms per call through the Python bridge on a 150k vocabulary, and 3 of the 8 schemas in my benchmark did not complete.
- Nothing here has been reported upstream or confirmed by the maintainers yet. Versions tested: llguidance 1.9.1, outlines-core 0.2.14, XGrammar 0.2.9.
Try it
git clone https://github.com/Flotrpy/sieve-df
cd sieve-df
cargo build --release
examples/quickstart.sh # bundled schemas, built-in vocabulary, no downloads
Each bug comes with a replay command and a markdown issue draft. Feedback is very welcome, especially from anyone who maintains one of these engines.
Comments
No comments yet. Start the discussion.