Law 17 · Scope & Design

Determinism at the Edges

Model in the middle, code at the boundaries.

Diagram explaining Determinism at the Edges

The principle

Validation, schema enforcement, retries, routing, and access control are not the model's job — they're code's job. The model is for judgment under ambiguity; deterministic code is for everything that must be correct every single time. Asking a probabilistic system to guarantee a contract is asking for the 0.1% that ruins you.

Why it happens

A sampled model is a probabilistic function, so any property you need true on every single call, like a valid schema, an authorization check, or a dedup guarantee, cannot rest on the model because even a one-in-a-thousand violation is unbounded loss at scale. The reliable pattern is to keep the model in the soft middle for judgment under ambiguity and wrap it in deterministic code at the boundaries that validates inputs, enforces output structure, and gates side effects. This is the core argument of the 12-factor agents framework: production-grade LLM applications are mostly deterministic software with model calls inserted at the few points that genuinely need language understanding, and the developer owns the control flow rather than delegating it to an autonomous loop. Asking a probabilistic system to provide a hard contract is asking for the rare violation that ruins you.

Watch for

In practice

You let the model decide whether an email is valid, format the output JSON, and enforce which users can trigger a refund, then one sampling roll in a thousand returns malformed JSON or green-lights an unauthorized action. Hard guarantees should never ride on a probabilistic system. Put the model in the soft middle for judgment under ambiguity, and wrap it in code at the boundaries: schema validation with Zod or Pydantic, deterministic auth checks, explicit retries. The contract belongs to code, not to a dice throw.

Apply it

  1. Validate and enforce output structure in code after the model, rejecting or repairing anything off-contract.
  2. Put authorization, routing, and retries in deterministic code, never in the model's discretion.
  3. Reserve the model for ambiguous judgment and let code own every guarantee that must hold every time.

The takeaway

Wrap the model in code you can trust. Let it reason in the soft middle, but put a deterministic shell around the inputs and outputs so the hard guarantees never ride on a sampling roll.

Sources and further reading

Related laws

Read every law in the digital edition Back to all 50 laws