Designing for Non-Determinism
Ask the same question twice and an AI feature may answer differently, even with every randomness setting turned off. Reliability does not come from forcing sameness. It comes from deciding what may vary and what may not, constraining the parts that must hold, measuring consistency by repeated runs and giving the feature somewhere safe to go when it is unsure.
After this chapter you can
- Write a variance budget stating which output parts may vary and a numeric threshold for those that must not.
- Measure consistency by running each test case about five times and reporting both the average and the all-runs figure.
- Place stable output parts on the highest workable rung of the constraint ladder, from fixed structure up to checks in code.
- Design a fallback chain with a cost and a limit at each step, plus an abstention trigger that can be measured.
- Explain why setting temperature to zero does not make a hosted model's output reproducible.
In September 2025, researchers at Thinking Machines Lab ran a simple test. They asked an open-weights model, Qwen3-235B-A22B-Instruct-2507, the same prompt, “Tell me about Richard Feynman,” 1,000 times, at temperature 0, which is the setting that should always pick the most likely next word. They got 80 unique completions. The most common one appeared 78 times. All the completions matched for the first 102 tokens, then split at token 103: 992 of them continued “Queens, New York” and 8 wrote “New York City”1. The researchers attribute the variation to the serving system: results depend on how requests are batched together on the server, and so on the load at that moment. When they used kernels built to ignore batch size, all 1,000 completions were identical1.
That is one model, one prompt and one team’s serving setup, and the finding should not be stretched to every model or API. What it supports is narrower and more useful for a manager: “set the temperature to zero” is not a way to buy reproducibility, and your team often cannot control the serving layer of a hosted model anyway. You have to design for variation, not hope it away.
Your engineers will meet this the first time a test passes on Tuesday and fails on Wednesday with no code change. It is also the moment a manager is tempted to ask for a fix that makes the model behave consistently. This chapter gives you a better request: a variance budget, which says what may vary and by how much, with constraints, fallbacks and signals to users that keep the rest of the feature dependable.
Level 1 taught that a system should be able to say it does not know, and escalate to a person. Here that principle turns into a design with a specific place in the feature, a threshold and an owner.
Where the variation comes from
Engineers often say the model is random, and that is only one of several sources. Treat each separately, because each has a different owner and a different remedy.
The sampling row has a footnote that managers should know. Providers are removing some of the knobs. Anthropic’s model documentation states that on Claude 4.7 and later models the temperature, top_p and top_k parameters return an error when set to a non-default value, and recommends guiding behavior through prompting instead2. That is a date-stamped fact about one provider as of October 2026, and other providers differ. A design that depends on a low-randomness setting could therefore break on a model upgrade, which is one more reason to avoid building correctness on it.
Decide what may vary: the variance budget
A feature’s output has parts, and the parts do not need the same consistency. A support assistant’s category label feeds a routing rule, so it must not flip between runs. Its drafted reply is read by a person, and different wording is acceptable as long as the facts stay the same. A cited policy number must be the same every time, or absent.
A variance budget is a short table that lists each part of the output, says whether it must be stable, may vary in wording or may vary freely, and sets a threshold on how often it may differ across repeated runs. The threshold is the important piece. “Reasonably consistent” is not a requirement, and “at least 97 percent of test cases give the same category on all five runs” is.
A budget also tells the team where to spend effort. Stable parts get constraints and checks. Free parts get nothing, which is cheaper; in this chapter’s judgment, forcing identical wording on a reply adds fragility without adding safety.
Measure consistency by repeating runs
A single run per test case hides variation, because a case that passes once may fail on the next run. The fix is to run each case several times, five is a workable start, and report two numbers: the average pass rate, and the share of cases that pass on every run. The second is the one a user feels.
The arithmetic is worth seeing once. Suppose, purely for illustration, a feature passes 90 percent of runs. If runs were independent, the chance of passing five in a row on a given case would be 0.9 multiplied by itself five times, about 59 percent. Real runs are not independent, so the real figure differs, and that is exactly why you measure it. The point is that a good-looking average can sit above a poor all-runs figure, and a user who tries the feature several times sees the poor one.
A benchmark paper makes the same point from another angle. The authors of τ-bench, which tests agents on customer-service tasks, propose a metric called pass^k for reliability across repeated trials. They report that state-of-the-art function-calling agents such as gpt-4o succeeded on fewer than half the tasks, and in the retail domain pass^8 fell below 25 percent3. Those figures come from one benchmark (the retail result is one of its two domains), one set of 2024 models and simulated users, and they say nothing about your feature. What they support is the method: a single-run score overstates reliability, so repeat the run.
Constrain what must hold
Where a part of the output must be stable, narrow what the model is allowed to produce. The tools are ordinary software.
- Schemas. Ask for output in a fixed structure and validate it. OpenAI reported that on its own evaluation of complex JSON schema following, a model with its Structured Outputs feature scored 100 percent, against under 40 percent for an earlier model without it4. That is the provider’s evaluation of one feature, and the documentation limits the claim: the feature ensures the response matches the schema, not that the values in it are correct5.
- Closed choices. For a label, let the model pick from a fixed list and reject anything else. A made-up category cannot reach the routing rule.
- Checks in code. Verify what can be verified: that a cited policy number exists, that a date is in range, that a total adds up. This catches an error that looks perfectly plausible, which a reader often misses.
- Retrieval and quoting. Where facts matter, require an answer to quote a source passage, and check the quote against the source.
A constraint guarantees shape, and shape is a weaker thing than truth. A schema-valid answer can still carry the wrong category, and a closed list can still contain the wrong choice. Constraints shrink the space of failures; evaluation tells you what remains in it.
Design the fallback and the abstention path
Even with a budget and constraints, some outputs will fail a check, and some inputs will be ones the feature should not answer. A dependable feature has an answer to “what happens next” before the first user arrives.
A fallback chain is an ordered list of what to try. A typical one is: retry once with a stricter instruction; try an alternative prompt or model; use a rule-based default; hand the case to a person; and as the last step, tell the user the feature cannot help with this and say what to do instead. Each step needs a cost, because retries multiply the bill and the delay, and a limit, because a loop that retries forever is its own incident.
Abstention, the feature’s decision not to answer, needs a trigger. Self-reported confidence is a weak trigger on its own: a stated “95 percent sure” is not a measured 95 percent unless your team has checked it against its own cases. Better triggers can be measured: the checks in code failed, the retrieved sources do not support the answer, a required field is missing, or repeated runs disagree. On that last trigger, Farquhar and colleagues report that sampling several answers and measuring whether they agree in meaning can flag arbitrary, incorrect generations6. The method targets that kind of error; a model that is consistently wrong would not be caught by disagreement. It costs several runs per request, so use it where an error is expensive.
The user also needs a signal; this chapter treats the following as good practice, not as a measured result. Mark generated content as AI-produced, show the sources used, let the user edit before anything is sent and make the “this is wrong” action one click. Those signals also feed your monitoring later in the module.
A team-sized worked example
The team here is imagined and so are its figures, which exist only to make the reasoning concrete. A team of five engineers builds a tool for a support group of thirty agents: it labels each incoming ticket with one of nine categories and drafts a reply. The first demo is convincing, then the team’s own tests show the label changes on repeated runs for some tickets.
The team lead asks for a variance budget before any more work. The table above is the result, and the numbers are illustrative. The category must match on all five runs for at least 97 percent of 200 test tickets (194 or more; an illustrative starting value). A cited policy number must be right or absent. Reply wording may vary freely, with the facts fixed.
The team then applies the rungs. The label becomes a closed choice among the nine categories, validated in code. The policy number is checked against the policy list, and an unverified number is stripped before display. The reply must quote a passage from the policy it relies on. Then it builds the fallback chain: one retry with a stricter instruction, then a rule-based default of “general inquiry” for the category, and an agent reviews the draft before it is sent in any case. If a ticket fails two checks, the feature shows no draft and says why.
The first measurement is 88 percent of cases (176 of 200) with the same label on all five runs, below the 97 percent bar. The team inspects the unstable tickets and finds that a pair of categories overlap in the instructions, rewrites the definitions, adds two examples and measures again: 96 percent. It then splits the pair by a rule on a ticket field. The final figure is 98 percent (196 of 200), and the lead approves the staged release. The budget did two things: it turned “inconsistent” into a number that could improve, and it stopped the team spending time on the reply wording, which was never at risk.
Setting expectations above and beside you
A variance budget is also a communication tool. Directors and product owners are used to software that gives the same answer to the same input, and a feature that does not looks, to them, like a defect. The manager’s work is to replace that expectation with a statement the team can keep.
A useful statement has three parts. First, what is fixed: “the category, the policy number and the amount never differ between runs, and we test that.” Second, what varies and why that is acceptable: “the wording of the draft differs, and an agent reads every draft before it goes out.” Third, what happens when the feature is unsure: “it shows no draft and routes the ticket to a person.” Stakeholders can accept that. They cannot accept “the AI is sometimes wrong,” because it gives them nothing to plan around.
Inside the team, make the budget a test and not a document. Put the repeated-run measurement into the same checks that run before every change to a prompt or a model, so a slip in consistency shows up as a failed gate on the day it happens and not in a user complaint a month later. The next chapters in this module build the evaluation set and the gate; this chapter only asks you to decide, in advance, what the gate will measure.
What this means for engineering managers
Monday action: ask the team to rerun your feature’s existing test cases five times each and bring you the average and the all-runs figure.
Variance budget for: ______ (thresholds are illustrative starting values; set yours from the cost of an inconsistent output)
Output part | May it vary? | Threshold over ___ runs | Constraint rung (free / schema / closed list / code check)
____________|______________|_________________________|_____________________
Fallback chain: step 1 ___ (cost ___, limit ___) -> step 2 ___ -> person -> "cannot help"
Paged when the last step fires more than ___ times per ___: ______ (name)
Check yourself
- Setting the temperature to zero makes a hosted model’s output reproducible.
- A feature that passes 90 percent of runs will pass 90 percent of cases on every one of five runs.
- A response that matches a JSON schema is therefore correct.
- Different wording across runs is always a defect.
- A variance budget gives each part of the output a threshold on how often it may differ across repeated runs.
- A fallback chain needs a limit as well as an order, or retries can become their own incident.
Reflection
What comes next
A variance budget is only as good as the cases you test it on. The next chapter, Building Evaluation Sets, covers how to assemble representative, versioned test cases from real inputs, edge cases and past failures.
Laws referenced
Not legal advice. Laws change; verify before relying on this, and consult counsel for decisions.
EU AI Act · EU
Regulation (EU) 2024/1689, as amended by Regulation (EU) 2026/1744
Risk-based rules. Prohibited practices include social scoring, untargeted scraping of facial images, and emotion recognition in workplaces and schools (with narrow exceptions). High-risk systems (Annex III: biometrics, safety components of critical infrastructure such as energy, water and traffic, employment and worker management, credit, education, essential services, law enforcement, migration, justice) need risk management, data governance, documentation, logging, human oversight, human oversight that keeps people able to understand the system, notice automation bias (over-reliance on its output), override it or stop it (Art. 14(4)), appropriate accuracy, robustness and cybersecurity (Art. 15), automatic logging of events (Art. 12), a provider quality-management system (Art. 17) and conformity assessment. An Annex III system is not high-risk if it poses no significant risk of harm, for example a narrow procedural or preparatory task that does not replace human assessment; systems that profile people are always high-risk, and a provider relying on this exception must document it and register (Art. 6(3)). Deployers of high-risk AI must use it as instructed, assign competent human oversight, monitor its operation, keep logs for at least six months and report serious incidents (Art. 26); employers must inform workers' representatives (Art. 26(7)). Public bodies, private providers of public services, and deployers of credit-scoring or life and health insurance pricing systems must carry out a fundamental-rights impact assessment before first use (Art. 27). Providers must run post-market monitoring (Art. 72). A deployer that puts its name on a high-risk system, substantially modifies it, or changes its purpose so that it becomes high-risk takes on the provider's obligations (Art. 25(1)). A substantial modification (Art. 3(23)) of a high-risk system needs a new conformity assessment, unless the change was pre-determined and documented at the first assessment, as with planned continuous learning (Art. 43(4)). Providers of general-purpose AI models (from 2 Aug 2025) must keep technical documentation, have a policy to comply with EU copyright law including text-and-data-mining opt-outs, and publish a sufficiently detailed summary of training content (Art. 53). Research, testing and development before a system is placed on the market or put into service is outside the Act, except testing in real-world conditions (Art. 2(8)). Since the 2026 Omnibus, the Art. 4 AI-literacy duty is an obligation of effort (take measures to support literacy), not of result. Fines reach EUR 35 million or 7% of global turnover for prohibited practices.
- 2024-08-01 — Entered into force
- 2025-02-02 — Prohibited practices (Art. 5) and the AI-literacy duty (Art. 4) apply
- 2026-07-27 — Omnibus softens Art. 4: providers and deployers must take measures to support AI literacy; no specific level must be guaranteed
- 2025-08-02 — General-purpose AI model obligations apply; governance and penalties regime in place
- 2026-08-02 — Transparency duties (Art. 50) apply: disclose AI interaction, label synthetic and deepfake content (marking for generative systems already on the market: 2 Dec 2026)
- 2027-12-02 — High-risk obligations for Annex III systems (e.g. hiring, credit, education, essential services) - moved from 2 Aug 2026 by the 2026 Omnibus
- 2028-08-02 — High-risk obligations for AI in products regulated under Annex I
Last verified 2026-10-06 · official text
References
- Horace He and Thinking Machines Lab. Defeating Nondeterminism in LLM Inference. Thinking Machines Lab: Connectionism. 2025.
- Anthropic. Model deprecations. Claude Platform documentation. 2026.
- Shunyu Yao, Noah Shinn, Pedram Razavi and Karthik Narasimhan. τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains. arXiv (2406.12045). 2024.
- OpenAI. Introducing Structured Outputs in the API. OpenAI. 2024.
- OpenAI. Structured Outputs. OpenAI developer documentation. 2026.
- Sebastian Farquhar, Jannik Kossen, Lorenz Kuhn and Yarin Gal. Detecting hallucinations in large language models using semantic entropy. Nature 630, 625-630. 2024.
Further reading
- Horace He and Thinking Machines Lab. Defeating Nondeterminism in LLM Inference. Thinking Machines Lab: Connectionism. 2025.
- Shunyu Yao, Noah Shinn, Pedram Razavi and Karthik Narasimhan. τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains. arXiv (2406.12045). 2024.
- OpenAI. Introducing Structured Outputs in the API. OpenAI. 2024.
Sources last verified 2026-10-12.