Skip to content
AVERITH
← All insights
ReliabilityNote / 0311 min read

Why probabilistic systems still need deterministic architecture

Models can propose. Policy, authorization, budgets, state transitions and recovery need explicit contracts.

Language models are probabilistic by construction. The same input can produce different outputs, a small change in phrasing can change behavior, and a model can produce a fluent, confident answer that is wrong. These are not bugs to be eliminated before production. They are properties of the component.

The tempting response is to compensate inside the prompt: add instructions, add examples, add stern warnings about what the model must never do. Prompts improve average behavior. They do not create guarantees. A system that moves money, changes records, sends messages or grants access needs guarantees, and those have to come from somewhere the model cannot talk its way around.

The architecture that works is a division of responsibility. The model proposes. A deterministic layer decides whether the proposal is well formed, permitted, affordable and valid in the current state, and only then commits it in a way that can be recovered.

The proposal boundary

PROBABILISTICDETERMINISTIC CONTRACTSMODELPROPOSALSCHEMAPOLICYBUDGETSTATEEXECUTEJOURNALREJECTED → BOUNDED REPAIR OR ESCALATE TO A HUMANMODELS PROPOSE. CONTRACTS DECIDE WHAT COMMITS.
Figure 1 — The model sits on the probabilistic side of an explicit boundary. Every proposal crosses deterministic checks before anything changes in the world, and every committed action is journaled.

01 / Boundary

Treat model output as a proposal, never as a command

The single most useful design decision is to make the model’s output a typed proposal: a structured request to take an action, with explicit fields, that some other component evaluates. The model does not call the payment API. It proposes a refund of a specific amount on a specific order for a stated reason, and the system decides.

This shifts the reliability question. Instead of asking whether the model will always behave, which no one can promise, the question becomes whether the boundary rejects every proposal that should not commit. That is a question about ordinary code, and ordinary code can be reviewed, tested and audited.

02 / Contracts

Output contracts: parse, do not hope

Structured output modes and schema-constrained generation have made well-formed output far more reliable, but well-formed is not the same as valid. A proposal can match the schema and still reference an order that does not exist, an amount above the purchase price or a customer the requester does not serve.

  • Validate structure with a schema, then validate semantics against the system of record: identifiers exist, amounts are within bounds, references belong to the right tenant.
  • When validation fails, return a precise error to the model and allow a small, fixed number of repair attempts. Unbounded repair loops are a cost and latency failure waiting to happen.
  • After the repair budget is spent, fail closed: reject, or route to a human with the proposal and the reasons it was refused.

03 / Authorization

Authorization cannot depend on what the model says

An agent with tools is a textbook confused deputy: a component holding privileges that can be induced to exercise them on behalf of someone who should not have them.1 Prompt injection makes the inducement easy. Instructions hidden in a retrieved document, an email or a web page can redirect a model that was only asked to read them.2 OWASP lists prompt injection first in its Top 10 for LLM applications.3

The defense is not a better instruction telling the model to ignore injected text. It is an architecture in which a successfully manipulated model still cannot do anything the requesting user could not do.

  • Execute every tool call with the requesting user’s identity and permissions, never with a broad service account the model can borrow.
  • Scope each tool to the narrowest capability it needs: read rather than write, one table rather than the database, one mailbox rather than the domain.
  • Make authorization decisions in code from the actor, the action and the resource. The model’s explanation of why an action is allowed is not an input.
  • Require explicit human confirmation for irreversible or high-impact actions, with the exact proposal shown, not a model-written summary of it.

04 / Budgets

Budgets are enforced from outside the loop

An agent loop that decides for itself when it is finished can also decide never to finish. Asking the model to be economical is a preference; a budget is a limit. Every run needs ceilings that the orchestrator enforces regardless of what the model proposes next.

  • Maximum steps and tool calls per run.
  • Maximum input and output tokens, and a monetary ceiling derived from them.
  • A wall-clock deadline, so a slow dependency cannot hold a run open indefinitely.
  • Per-tool rate limits, so one run cannot exhaust a shared quota or overload a downstream system.

When a ceiling is reached, the run should stop in a defined state with its partial work recorded, not crash halfway through an action.

05 / State

State transitions belong to a state machine

Business processes have rules about order. A refund is reviewed before it is approved and approved before it is paid. A model asked to move a case forward may skip a step because skipping it looks reasonable in context. The system should make that impossible rather than unlikely.

Model the workflow as an explicit state machine. The model can request a transition; the state machine accepts it only if it is legal from the current state. Terminal states stay terminal.

Current stateAllowed next states
requestedunder_review, rejected
under_reviewapproved, rejected, needs_human
needs_humanapproved, rejected
approvedpaid
paid / rejectednone — terminal

Put together, the boundary is small enough to read in one screen. Each line is a deterministic contract the model cannot override:

Illustrative TypeScript / commit boundary

const allowed: Record<RefundState, RefundState[]> = {
  requested: ["under_review", "rejected"],
  under_review: ["approved", "rejected", "needs_human"],
  needs_human: ["approved", "rejected"],
  approved: ["paid"],
  paid: [],
  rejected: [],
};

async function commit(run: Run, raw: unknown) {
  const proposal = RefundProposal.parse(raw);           // contract
  await authorize(run.actor, proposal);                 // policy
  run.budget.charge(proposal.estimatedCost);            // budget
  if (!allowed[run.state].includes(proposal.next)) {    // state
    throw new InvalidTransition(run.state, proposal.next);
  }
  return execute(proposal, {
    idempotencyKey: `${run.id}:${run.step}`,            // recovery
  });
}

06 / Recovery

Recovery assumes the run will be interrupted

Long-running workflows will be interrupted by deploys, timeouts, provider errors and crashed workers. Recovery has to be designed in, and it is harder than in ordinary services because re-running a model step does not reproduce the original result.

  • Give every side-effecting action an idempotency key derived from the run and step, such as run_id:step, so a retried call cannot charge, send or create twice.
  • Journal each model output and each committed action durably before moving on. On resume, replay the recorded outputs instead of sampling the model again.
  • Checkpoint at step boundaries so a resumed run continues from the last committed state rather than starting over.
  • For multi-step processes without a single transaction, define compensating actions for each step, the pattern long described as sagas.

The saga pattern predates language models by decades.4 That is the point: the reliability problems of AI workflows are mostly familiar distributed-systems problems, with a nondeterministic component in the middle.

07 / Determinism

Do not rely on the model to be deterministic

Setting temperature to zero reduces variation, but in practice it does not guarantee identical outputs across runs, model versions or providers. Batching, hardware and silent model updates all introduce drift. Designs that depend on the model returning exactly the same answer twice are fragile.

Treat the recorded output as the source of truth for what happened. Pin model versions where the provider allows it, record the version on every call, and evaluate before changing it, in the same way a database or runtime upgrade is evaluated.

08 / Testing

The deterministic layer is where guarantees are tested

One practical benefit of this architecture is that it separates two kinds of testing. The model is evaluated statistically, against datasets and tolerances. The boundary is tested like any other code, with unit tests and property tests that feed it adversarial proposals: unauthorized resources, illegal transitions, oversized amounts, malformed fields and duplicated requests.

Those tests can make absolute claims. No proposal from any model, however manipulated, can pay a refund that was not approved, act outside the requesting user’s permissions or exceed the run’s budget. That is the kind of statement a security review, an auditor or an operations team can rely on, and it is a statement no prompt can make.

Probabilistic components are what make these systems useful. Deterministic architecture is what makes them safe to operate.

References

  1. 1. Hardy, N. (1988). The Confused Deputy (or why capabilities might have been invented). ACM SIGOPS Operating Systems Review, 22(4). doi:10.1145/54289.871709
  2. 2. Greshake, K. et al. (2023). Not what you’ve signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection. arXiv:2302.12173
  3. 3. OWASP. Top 10 for Large Language Model Applications. genai.owasp.org
  4. 4. Garcia-Molina, H. and Salem, K. (1987). Sagas. Proceedings of the ACM SIGMOD International Conference on Management of Data. doi:10.1145/38713.38742

About the author

Author

Nishant Kumar

Software Engineer, Uber

Works on large-scale Enterprise data platforms at Uber. Contributed the evaluation design in this note.