A model of a personal agent, and the notation used throughout
The definitions every unit reuses: runs, tools and effects, principals and provenance, the gate and what it guarantees against any model, the journal, and the estimators used to measure all of it. Each later chapter states its claims in these terms.
The chapters explain mechanisms in prose and code. This page states the same things once, compactly, so that a claim made in one chapter can be compared with a claim made in another and so that problems can ask for an argument and not an opinion. Nothing here is needed to follow a chapter. All of it is needed to do the problem sets.
Two kinds of statement appear in the course and are kept apart. A property is something the program guarantees whatever the model does; it is argued from the code and tested without a model. A measurement is something observed over runs of a real model; it carries a sample size and an interval and can be wrong. Much confusion about agents comes from stating a measurement as if it were a property ("the assistant does not follow planted instructions") or the reverse.
Runs, contexts and tools
A model M is a random function from a context to an action. A context c = (s, h) is a fixed part s (instructions and tool descriptions) and a history h, a sequence of items. An action is either text for the owner or a tool call (τ, x): a tool name and its inputs. Nothing is assumed about M except its type. In particular it is not assumed to follow s.
The world σ is everything outside the program that a tool can read or change: mailboxes, calendars, databases, the web, the program's own files. A tool is a function τ : (σ, x) → (σ′, r) giving a new world and a result r that is appended to the history. The effect of a call is the difference between σ and σ′, and falls in one or more of six classes:
- read
- σ′ = σ. The only consequence is that r enters the context.
- add
- Something new appears that only the owner sees and the owner can remove; nothing that existed is altered.
- change
- Something that existed is altered.
- send
- Information reaches a principal other than the owner: a recipient, a website, a vendor.
- persist
- Something is written that will be placed in the context of a later run: a memory, a skill, a routine.
- destroy
- Something is removed and cannot be restored by the program.
A run is a sequence c₀ →ᵃ⁰ c₁ →ᵃ¹ … →ᵃⁿ in which each aₜ is drawn from M(cₜ), each tool call that executes appends its result, and the last action is text, unless the program ends the run first: at a ceiling on cost or steps, or because it is getting nowhere. A run is attended if the owner can be asked a question during it and unattended otherwise.
The class of an effect belongs to the call, not to the tool. calendar_create with no guests is an add; with a guest it is a send. Most mistakes in gate design come from classifying tools when it is calls that have effects.
Principals and provenance
Four kinds of principal can put text in a context. The owner O types messages. The program P writes s, labels and the questions the owner is asked. Outsiders S write everything a tool returns from the world: mail, pages, files, records, other people's messages. Vendors V write tool descriptions for services they run. Only O and P are trusted to state what the owner wants.
Every item of history has a provenance in {O, P, S, V}, fixed by the code path that appended it and never by what it says. The record of reading T is the set of kinds of outside material appended to the current context, with fingerprints of its details. T = ∅ means the context holds only the owner's and the program's words. T grows when a tool returns outside material and is emptied only when the context itself is.
This is the two-point integrity lattice of the information-flow literature, S ⊑ O, applied to a context window, with V counted with S and P with O: a model's output can be influenced by anything in its context, so the output of any step after an outside read must be treated as having provenance S. The model cannot be asked which of its words came from where. This is the fact the safety chapters are built on.
The gate
A gate is a deterministic function G : (τ, x, T) → {allow, ask, refuse} evaluated by the program before every tool call. On ask the program writes a question q(τ, x) from the call's own fields and waits for the owner's decision d ∈ {yes, no, timeout}. A call executes if and only if G = allow, or G = ask and d = yes for that exact (τ, x).
If the only code path from a model's output to a tool's execution passes through G, then for every model M, every context and every run, each executed call either was allowed by G or was approved by the owner on a question derived by code from that call.
Argument. By induction on the length of the run. The statement quantifies over all M because the proof never inspects M: it uses only the structure of the program. The hypothesis is the one that fails in practice. It is the first of the three requirements of a reference monitor: always invoked, tamper-proof, and small enough to be checked.
Let A(T) = {(τ, x) : G(τ, x, T) = allow}. Suppose the hypothesis of Property 1 holds, and that after any outside read the model does whatever the outside text says. Then the effects that outside text can bring about without the owner seeing a question are exactly the effects of calls in A(T), for the T ≠ ∅ in force when each call is made, and nothing else.
Consequence. The security of an attended run against a fully adversarial model is a statement about the gate alone. It can be checked kind of call by kind of call, with chosen inputs, without calling any model; because the inputs are unbounded, such a check covers the inputs tried and those the gate's rule treats alike. A gate is sound for a set of effect classes E if no call in A(T), T ≠ ∅, has an effect in E. The design problem is to choose E.
Property 2 does not say the owner is safe. It leaves three gaps, and each has its own chapter. Calls in A(T) still have effects, and a permitted effect can carry a harmful meaning. The owner's yes is assumed to be informed, which depends on what q shows and on how often the owner is asked. And an unattended run has no d, so for it ask must mean refuse or defer.
A gate confines outside material for a sink (send, persist, or both) if, for T ≠ ∅, no call with an effect in that sink is in A(T) unless its inputs are a function of the owner's words alone. This is noninterference from S to the sink, with the owner's approval as the only declassifier, weakened in one way: whether and when such a call is made may still depend on what was read. A gate confines on copies if, for T ≠ ∅, no call in A(T) with an effect in the sink has inputs that contain a detail fingerprinted in T and absent from the owner's words. That is weaker again: it concerns explicit copies of fingerprinted details, and says nothing of what a model encodes in the inputs of calls that are allowed.
The cost of asking
A gate that asks about everything is sound for every class and useless, and a formal treatment has to say why. Let λ be the rate of questions per day, p the fraction of questions that are about a call the owner would not want, and a(λ) the probability that the owner approves such a call when asked. The expected number of unwanted effects per day that the owner approves is
H = λ · p · a(λ)
The literature on warnings and on supervising automation gives the shape of a: it rises with λ and with the fraction of questions that are routine. So lowering λ by letting harmless calls run unasked can lower H even though it enlarges A(T). The course treats the number of questions per task as a measured quantity with a target, like accuracy and cost. a(λ) is not measured anywhere in this book; it is the least-known quantity in the design.
The journal
The journal J is an append-only sequence of records, one for every message, model call, tool call, gate decision and failure. Derived state is any value computed as a pure function of a prefix of J: what a task cost, whether one is running, what was interrupted, how the assistant is used.
If every figure the program reports is derived state, then two reports of the same figure computed from the same prefix of J cannot disagree, a restart loses nothing that was appended, and any report can be recomputed later from J under a corrected function. The cost is that a fact the journal does not record cannot be recovered, so the choice of what to append is the choice of what can ever be known.
Measuring
An evaluation has cases i = 1…n, each run k times. Run j of case i has score yij ∈ [0, 1]. The case mean is ȳi = (1/k) Σj yij and the suite's score is Ȳ = (1/n) Σi ȳi. The case is the unit of analysis. Runs of one case are not independent, so an interval computed over all nk runs as if they were is too narrow.
- Interval
- A percentile bootstrap over cases: resample the n case means with replacement, recompute Ȳ, and report the 2.5th and 97.5th percentiles.
- Paired difference
- For two versions A, B run on the same cases, Δ = (1/n) Σi (ȳiB − ȳiA), with a bootstrap over the per-case differences. Pairing removes the variance between cases, which is usually most of it.
- Noise floor
- The size of |Δ| seen when A and B are the same version: estimated by splitting the k repeats of one version into two halves (the first ⌊k/2⌋ against the rest), taking the half-width of the 95% interval of their paired difference, and scaling it from halves to whole runs: for halves of a and b repeats, dividing by √((1/a + 1/b)·k/2), which is √2 when the halves are equal. A change smaller than this has not been observed. The floor belongs to the set of cases it was measured on: over half of them, a difference varies about √2 times as much.
- Reliability
- passk, the fraction of cases in which all k repeats succeed. For a case with per-run success p it is pk, so a suite at 95% per run can sit near 77% at k = 5.
- Agreement
- For two markers of the same yes/no statements, observed agreement po and Cohen's κ = (po − pe) / (1 − pe), where pe is the agreement their own rates of yes would give by chance.
- Headroom
- 1 − Ȳ. A suite with headroom below its noise floor cannot show an improvement, whatever is done to the system.
If a change is chosen by looking at scores on a set D and kept only when a paired difference on a disjoint set H, never looked at while choosing, exceeds the noise floor, then the probability of keeping a change with no true effect is bounded by the level of the test on H, however many candidates were tried on D. That level is about 2.5% only if the floor was measured for a comparison over H; a floor measured over all cases is about √2 too small for it. The bound is spent each time H is consulted: after m looks the chance of at least one false keep is at most m times the level.
Cost
One model call with nin fresh input tokens, ncr read from cache, ncw written to cache and nout output tokens costs
C = pin·nin + pcr·ncr + pcw·ncw + pout·nout
A conversation of m calls that starts with c₀ tokens of fixed context and adds δ tokens per call sends Σt=1…m (c₀ + tδ) = m·c₀ + δ·m(m+1)/2 input tokens in all. Without a cache the cost of a conversation therefore grows with the square of its length, and three ways to spend less are the three terms: a smaller c₀, a smaller δ, and a smaller m. Most design decisions in the cost chapter are one of these; the rest lower a price, by a cheaper model or a cheaper route to the same information.
How the chapters use this
The four properties here are the ones every unit leans on. Units add their own, named by what they say; the first, that an approval is a capability for exactly one call, is Property 5 in Chapter 8.
Each chapter has a section headed The theory that states its central claim in these terms and says which kind of claim it is. Problems marked analysis ask for an argument from these definitions. Where a chapter's subject has no useful formal statement, it says so; pretending otherwise would be the opposite of rigour.