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 aren't the model's job. They're code's job. The model is for judgment under ambiguity, and deterministic code is for everything that has to 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

The model is the wrong place for guarantees. If output shape, authorization, retries, dedupe, or routing must be correct every time, put it in code. Let the model handle judgment under ambiguity, then validate and gate its output at the boundary. This is the production pattern behind 12-factor agents: mostly deterministic software, with model calls where language judgment is useful. A one-in-a-thousand schema or permission failure is still a production incident at scale. Hard contracts belong outside the sampled text stream.

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 your hard guarantees never ride on a sampling roll.

Sources and further reading

Related laws

Get the audit kit Access the buyer edition Back to all 50 laws