# stepmold-bench Runs every gold case in stepmold's example packs against one real model, twice: once through stepmold, and once through a plain pipeline that walks the same graph with the same prompts. It writes one JSONL record per model request and one per case-run. Those files are the raw data for the public Hugging Face dataset. Standard library only, Python 3.9 or newer. It never downloads or runs a model. It talks to an OpenAI-compatible server (vLLM, llama.cpp-server, SGLang, a hosted API). ## What it measures stepmold says four mechanisms keep a small model reliable over many steps: 1. The node's JSON schema is sent to the server as a decoding grammar. 2. Every answer is checked before it is committed: it must parse, fit the schema, and pass the node's optional `assert:`. 3. A rejected answer is drawn again, up to the node's `retries` (default 2). Each new draw gets a new seed, a higher temperature and a description of what was wrong, never the rejected answer itself. When the retries run out, the node's `on_fail` edge is taken. 4. A gate node (`samples:`, `agree:`) draws several answers and only commits when enough of them match. The bench switches all four off in the plain arm and keeps everything else, so the difference between the arms is what the four are worth on that model. The gold cases are the 86 in stepmold's `examples/` (7 packs). A case passes when `stepmold.eval` passes it: every expected field matches, and the run ends at the expected end node when the case names one. Two things to know about the gold before reading any number: - The labels were written by one person, to make a scripted model pass. stepmold's own `docs/BENCHMARKS.md` found two unrelated models agreeing with each other against the gold on 4 of 12 support_triage cases. A pass rate here is agreement with that gold. - refund_desk's case "approve burns its ladder -> nothing is issued" only passes when `approve` fails three times in a row or its draws disagree. A capable model rarely does that, so expect this case to fail in every arm. ## The arms Both arms run stepmold's own walker (`stepmold.graph.run`) through stepmold's own scoring (`stepmold.eval.evaluate`), one case at a time. Prompts are rendered by the same stepmold code from the same templates, so for the same state the prompt text is identical, byte for byte. Both keep `two_stage` think passes, which are prompt design, not checks. The stepmold arm is `stepmold eval` exactly. The plain arm is the "unverified arm" of stepmold's `tests/production/test_longhorizon.py`, pointed at a real model: a copy of the pack with the checks taken out, run behind a small adapter. | | stepmold arm | plain arm | |---|---|---| | Grammar in the request | the node's schema, sent the `--grammar-mode` way (default `response_format`) | none. The backend runs in grammar mode `none`, and the request has no `response_format` or `json_schema` field | | Reading the answer | `stepmold.verify.extract_json`: the whole reply, a code fence, then the last `{...}` | the first JSON object in the reply. A `{` that does not start valid standard JSON is skipped | | Schema check | yes | no | | A generate node's `assert:` | checked before the commit | dropped | | Retries | the node's `retries` (default 2) | none | | Gate (`samples`, `agree`) | as the pack says | one draw | | `on_fail`, `on_unsure` on a generate node | taken when retries run out, draws disagree, or the prompt cannot be rendered | removed | | An answer with no JSON object | rejected and drawn again | commits nothing; the walk goes on along whatever edge the state allows | | A prompt that needs a field nobody wrote | `on_fail` | the case ends as crashed | | Assert nodes, tool nodes, end nodes, edges, `when:` routing, `max_steps` | as the pack says | the same | In code: `bench.plain_pack` gives every generate node `grammar: {"type": "object"}`, no `assert:`, `retries: 0`, no `samples` or `agree`, and no `on_fail` or `on_unsure`. `bench.PlainModel` sits between stepmold and the server. It never forwards a grammar, returns the think pass as it came, and turns each answer into its first JSON object (or `{}` when there is none) before stepmold's verify sees it. That verify then only checks "is an object", which always holds, so nothing is ever rejected or retried. ### What the plain arm still gets from stepmold Running the plain arm on stepmold's walker keeps the comparison paired. It also brings a few things a hand-written pipeline would not have: - The walker refuses a commit that would overwrite a run input (`StateCollision`). If a plain answer repeats an input key such as `ticket`, the case ends as crashed, where a pipeline doing `state.update(answer)` would overwrite it and carry on. - verify still refuses a value nested more than 64 levels deep, which crashes the case. - A generate node with `output:` (commit under one key) would get `{}` under that key for an answer with no JSON object, instead of nothing. None of the seven packs has one. - Assert nodes and tool nodes keep their `on_fail` edges. content_moderation's `gate` and invoice_extract's four checks still divert bad state to their review paths in the plain arm. - Both arms get stepmold's decomposition: small nodes, each with its own fresh prompt. That is structure, and the longhorizon test keeps it in its naive arm too. ### The format problem, and the plain_schema arm None of the packs' answer prompts asks for JSON, and some never name the keys. support_triage's classify prompt ends "Answer with the category only." The grammar is what tells the model the shape. With identical prompts and no grammar, the plain arm's model is never told the format. The first live run shows it. gpt-oss-120b answered classify with the right word in plain text ("billing", "technical"). Nothing was committed, the next prompt could not be rendered (`MissingVariable: {category}`), and both cases crashed after one call. Some servers also show the schema to the model: on Cerebras the same rendered classify prompt cost 305 prompt tokens with `response_format` and 168 without it. So the plain arm mostly measures "the model was never told the format", and that will hide what verification, retries and the gate add. The opt-in arm `plain_schema` separates the two. It is the plain arm with the node's schema added to the end of each answer prompt, in the exact words stepmold's own `json_object` grammar mode uses ("Reply with JSON matching this schema:" and the schema). The text is built by stepmold's backend code. Nothing else changes and no constraint is sent. Run it with `--arms stepmold,plain,plain_schema`. ## First live check 2 November 2026, Cerebras `gpt-oss-120b`, `response_format`, reasoning reserve 600, support_triage, first 2 gold cases, 1 run, stepmold at 38235ab: | Arm | Case 1 | Case 2 | Calls per case | Tokens per case (prompt / completion / reasoning) | |---|---|---|---:|---| | stepmold | passed, 7 of 7 fields | silently wrong, 4 of 7 | 5 | 1564 / 652 / 442 | | plain | crashed after classify | crashed after classify | 1 | 164 / 40 / 28 | | plain_schema | silently wrong, 6 of 7 | silently wrong, 4 of 7 | 5 | 1214 / 577 / 355 | No retries in any arm. Median call latency was 618 ms over 22 calls. In case 2 both arms that finished called a crash on launch p0 and escalated it, where the gold says p1. That is the kind of label disagreement described above. ## Running it The bench imports stepmold from `--stepmold PATH` (default `~/Documents/GitHub/stepmold` when it exists), otherwise from the installed package. `pip install` does not ship `examples/`, so with an installed copy pass `--examples` pointing at a clone of the same commit. Each results file records the stepmold version and commit it ran. ### vLLM on Kaggle ```bash git clone https://gitlab.com/ahkamboh/stepmold /kaggle/working/stepmold git -C /kaggle/working/stepmold checkout 38235ab pip install /kaggle/working/stepmold # or: pip install git+https://gitlab.com/ahkamboh/stepmold@38235ab vllm serve Qwen/Qwen2.5-7B-Instruct --port 8000 & # wait until http://localhost:8000/v1/models answers python3 bench.py --stepmold /kaggle/working/stepmold \ --model 'openai:http://localhost:8000/v1#Qwen/Qwen2.5-7B-Instruct' \ --label qwen2.5-7b-instruct --concurrency 8 python3 summarize.py results/qwen2.5-7b-instruct.jsonl ``` vLLM needs no key, so leave `STEPMOLD_API_KEY` unset. For Qwen3, turn its thinking off with `--extra-body '{"chat_template_kwargs": {"enable_thinking": false}}'`. ### Cerebras ```bash export STEPMOLD_API_KEY=... # the Cerebras key; the bench never prints or writes it python3 bench.py --model 'openai:https://api.cerebras.ai/v1#gpt-oss-120b' \ --grammar-mode response_format --reasoning-reserve 600 \ --label gpt-oss-120b --concurrency 4 python3 summarize.py results/gpt-oss-120b.jsonl ``` gpt-oss-120b thinks before it answers, and its thinking counts against the same `max_tokens` as the answer. Nodes budget 24 to 512 tokens for the answer alone, so without headroom a node can spend its whole budget thinking and come back empty. `--reasoning-reserve 600` adds 600 to every request, the value stepmold's BENCHMARKS.md used for this model. Lower `--concurrency` or raise `--http-retries` if the account is rate limited; stepmold honours `Retry-After` up to 60 seconds. ### Options | Flag | Default | What it does | |---|---|---| | `--model` | required | a stepmold model spec, `openai:#[#[#]]`, or `fake: