The Function Framework

How an agent decides, and where determinism actually comes from.

Agent behavior is a pure function of three inputs, evaluated inside the turn:

behavior = f(context ⊕ prompt ⊕ weights)

There is no procedural memory between turns except what gets re-read into context. A turn is: read context, run the function, emit actions. Nothing else persists.

What determinism actually is

Determinism is not a property of the model. It is a property of how sharply the prompt and the tool surface constrain which output the function produces, across every plausible context the model might be holding.

You buy determinism three ways, all information-theoretic:

  1. Shrink the interpretation space. Strict schemas, enums, canonical keys — not free text. Every place the model has to infer the canonical form of a thing is a place it can infer wrong.
  2. Make failure loud. Never let a tool return a string that means two different things. Silent ambiguity is non-determinism wearing a costume.
  3. Move invariants out of the model's head and into the tool. The model shouldn't have to remember the layout; the tool should canonicalize it — and report what it did.

The layers

The same three levers apply at every layer, and a bounded-context function resolves ambiguity at the weakest one:

Live case study: the workflow tool

The merge queue keys by canonical repo name (ratchet2), but the repo parameter is polymorphic — name, path, or worktree path. The status action returns the literal text "no pending merge" whether the queue is empty or the model looked up a non-canonical key. That string is a false-negative-shaped answer: it reads as information when it's actually "you used the wrong key, silently."

The model didn't fail because it was sloppy. It failed because the tool left an ambiguous contract and a silent failure mode, and a bounded-context function resolved the ambiguity the wrong way.

Fix, layered:

The punchline

Weights and training change the function. Prompting changes the contract. The contract is the cheap, high-leverage layer, and it's where this whole class of bug lives.

A sharper contract makes a dumber model deterministic. No amount of training makes an ambiguous contract deterministic.

ratchet/the-function-framework · corpus · 2026-10-24