The controller holds the authority — study guide

The concept's fragments, read in order.

For your capstone Run a coding agent you don't have to trust

Your controller is the one program in the project that acts. It holds every version-control and deploy credential, performs every commit and branch move, and keeps the record of what is done; the agent edits files in its own workspace and hands back a result.

Say the agent's run on task T-17 ends with a result listing edits to src/billing/round. The controller confirms the run has stopped, snapshots the workspace and computes the difference itself: only paths this role may write, no protected file touched, no link pointing out of the workspace. Only then does it commit, parent pinned, and move the branch by compare-and-swap. One write into the checks directory and the whole run would have been rejected.

Agents propose, the controller acts

the agent proposes; only the controller acts on the world sandbox agent no commit, tracker or deploy credential reads a snapshot edits workspace files returns a result its output is a proposal proposal files, result controller credentials state store version control deploy code limits and launch checks the world repository tracker, APIs environments commit, merge write deploy a direct effect from the agent: no credential, no route
Inside the sandbox the agent reads a snapshot, edits workspace files and returns a result, holding no commit, tracker or deploy credential; the controller outside it holds the credentials, the state store, version control, deploy code, limits and checks, and every commit, external write and deploy reaches the world only through the controller, while a direct effect from the agent has no credential and no route.

A single tool call already follows one rule: the model proposes; your program executes. An agent doing real work, such as a coding agent fixing a bug across a dozen files, stretches that rule over many steps, and the temptation is to let it act directly: run git commit itself, push its own branch, file its own issues. Merging and deploying are already off the table for an agent; this concept takes the rule to its conclusion instead. The agent edits files in a workspace of its own and hands back a result. Everything that changes the world after that, every commit, merge, external write and change to the record of what is done, is carried out by the controller, through one path.

The controller is the program that starts the agent, holds the credentials, runs the checks and decides what happens next. Three kinds of thing live in it and nowhere else: every effect (any write outside the agent's own workspace), every privileged step (deploys, teardowns, anything that needs a credential the agent does not hold) and every limit (steps, time, spend, which tools exist at all). Whatever the agent produces is a proposal, and it works like a clerk who drafts letters for an official: the clerk may write anything, but only the official's seal makes a letter count, and the seal stays in a drawer the clerk has no key to.

"Code the agent cannot reach" has a precise meaning, and it is not an instruction. The controller's code runs as a different process, outside the sandbox, the contained environment the agent's commands run in. Its credentials sit in files and memory the sandbox does not show. Its record of state is not in the agent's view of the filesystem, and there is no network route to it from inside. A line in the prompt saying "do not commit" changes none of that, and none of it depends on the agent agreeing. Reach is decided by where things live, and it holds only as long as that wall holds: an agent that can read the controller's token has the controller's authority. Building the wall is a subject of its own.

One exception carries over from tool use. Some providers run built-in tools on their own servers, where only who executes the call moves. Such a tool performs effects outside the controller's path, so under a controller it is either switched off or counted as something the agent can do on its own.

Only the controller moves the state

Every controller keeps a record of where the work stands: what is planned, built, checked, merged. That record decides what happens next, so it carries authority, and the rule is that only the controller changes it. Agents submit work and evidence. They never write the record, and nothing an agent says satisfies a gate. The record works like a scoreboard that only the official scorer may change: players can shout that they scored, but the board moves only when the scorer has seen the ball go in. The failure this answers is progress that exists only because something wrote it down.

Field recordIn one real system, the project's state file recorded nine build stages as implemented on main, with the note "pipeline tests require the live stack, not run here". CI ran for the first time that same day and failed every run. The first green run came three days later, after four consecutive failures: lint had never actually been clean, the secret scanner lacked a permission, two test configuration files collided, a stub logging component had a bug, and one service's test suite could not run in CI at all. The test debt closed two days after that had been hiding a real production bug, a database column for network addresses that rejected the string unknown. The process template had only asked whether the pipeline test was done, yes or no. What changed: done became an event the machine verifies in a clean environment, and completion cannot be recorded without the identity of a check run.

Field recordIn the same system, a hand-edited state file read "Phase 1, Design, 44%" while production shipped 18 releases, and it still read that way when the repository was reviewed months afterwards. The script that rewrote it with regular expressions corrupted its own output table, and when two branches were stacked, that one file was the source of every merge conflict. The successor's rule: derive state from artifacts; never author it.

In the successor, state lives in a store that only transition functions write. Each transition runs in one transaction together with an append-only event, and records the subject, the revision, the evidence and the actor who approved it. The user interface and the command line are clients: they ask the controller for a transition and hold no state of their own. An agent can still claim anything it likes in its result; the claim simply has no path to the record. Which evidence a transition may accept is a subject of its own.

Reads before, writes after

reads before, writes after: only the controller writes, and only once the agent has stopped prepare workspace code + state snapshot reads before sandbox agent edits files returns a result stops confirm stopped nothing still writing snapshot validate the difference only this role's paths no protected files no links out no version-control metadata refs and checkouts unchanged all pass commit with parent pinned, move branch by compare-and-swap any fails reject the whole run no partial acceptance every box outside the dashed sandbox is the controller; the agent holds no commit, branch or tracker credential
The controller prepares a workspace with a state snapshot, the agent edits files inside the sandbox and returns a result, the controller confirms the agent has stopped, snapshots and validates the difference against its rules, and then either commits with the parent pinned and moves the branch by compare-and-swap, or rejects the whole run with no partial acceptance.

For a coding agent the effect path has a concrete shape. Before the run, the controller prepares a workspace: a checkout of the code plus a snapshot of whatever project state the agent needs to read. The agent edits files there and ends with a structured result. After the run, the controller performs every commit (a saved snapshot of the files in version control), every branch update, merge, issue creation and external write. The agent holds no version-control or tracker authority at all.

This arrangement was learned the hard way.

Field recordIn one real system, a coding agent that did its own version control was put in a sandbox with a read-only filesystem outside its workspace. The build role then could not create a branch or commit. In a second run with the network denied, the reviewer's comment died and the implementer's read of project state was refused; the record notes that under a network-disabled sandbox "no role can complete". An agent that holds effects either keeps that authority inside the sandbox, or loses it and breaks the workflow. The fix moved version control to the controller, before and after each run: "reads before, writes after; effects are an allowlist".

The care goes into the after half. The controller snapshots the workspace only once the agent has been confirmed stopped, so nothing is still writing. Then it validates the difference: only paths this role may write, no protected files touched, no symbolic links pointing out of the workspace, nothing under the version-control metadata, and branch references and checkouts unchanged. If every rule passes, it commits with the parent commit pinned and moves the branch by compare-and-swap, recorded in a journal first. Git supports this directly: git update-ref, given the old value, moves a branch only if it still points where the controller last saw it. If any rule fails, the whole run is rejected. There is no partial acceptance; a run that broke one rule contributes nothing.

The setup taught for AI-assisted operations, an identity of its own that pushes only to its own branch prefix and opens pull requests, is a sound first step, and everything it forbids stays forbidden: no merge, no deploy, no edits to CI, a review that never counts. A controller goes one step further for the reason the story above shows: inside a sandbox, a push credential is one more secret the agent can read and use for whatever the token allows. So the controller holds that identity and pushes the commit itself; the branch, the pull request and the protection on the main branch stay as before. Nothing here is special to code, either: any tool-using agent can work the same way, proposing effects that the controller applies.

Every effect needs an owner

Taking authority away from agents has a cost that is easy to miss. Every effect they used to perform stops happening unless the controller is given it explicitly, and often nothing raises an error when it stops. The work stalls or piles up quietly, and the numbers can even look better.

Field recordIn one real system, a sandboxed planning agent could no longer create its work items on the version-control host. Every run of one backend stalled at planning. The comparison scoreboard showed that backend as a "5x efficiency" win, because the later roles never ran. Once the controller, running as a background worker, created the work items from the plan files, four more follow-up defects were found in live runs. The lesson recorded: side effects a contained role cannot perform belong to the controller.

Field recordIn the same system, once agents lost version-control write access, plans, contracts, design decisions and audit reports were left uncommitted. Nothing owned committing them, and the gap stayed open for 42 days. A later benchmark still reproduced it, because the fix sat behind settings that were off by default. Two lessons came out of it: every artifact needs an owner with a commit path, and "implemented functionality is not necessarily an effective default".

So when you move effects to the controller, make the move an inventory rather than a hope. List every effect the old workflow produced, name the controller step that now performs each one, and treat an effect with no owner as a defect. Make sure the fix is switched on where the work actually runs, not only present in the code. And judge a run by whether the work it was for got done, not only by what it cost: a run that skipped half its steps is very cheap.

Deploys are code with no model behind them

a deploy runs only on a single-use capability, checked before any host call agent result changed files summary, findings no deploy field request a deploy? no field to ask with, no deploy grant frozen record of intent mints single-use capability environment operation attempt generation artifact digest exact service names given deployer fixed code, no model checks it against the store match host call mismatch refused, visibly
An agent's result has no field that can request a deploy and its grant has no deploy capability, so its request stops before the deployer; a deploy runs only when a frozen record of intent mints a single-use capability naming environment, operation, attempt, generation, artifact digest and service names, which the deterministic deployer checks against the store before any host call, refusing on any mismatch.

Some steps carry more authority than any agent should hold: deploying to an environment, tearing one down, anything that needs a production credential. Under a controller those steps are deterministic code, fixed logic with no model behind it, and no agent holds a deploy credential or deploy authority. This goes one step past the familiar rule that an agent may open a pull request but may not merge it or deploy. The component that deploys is not an agent at all.

Two layers keep it that way. First, no agent's result format has a field that can request a deployment, so even a perfectly formed result cannot ask for one, and no agent's grant includes a deploy capability. Second, the deployer does not act on a bare instruction either. Each deploy or teardown call takes one single-use capability, an object that carries the authority for exactly one operation. It is minted from a frozen record of intent and names the environment, the operation, the attempt, the generation, the digest (a content hash) of the artifact and the exact service names. Before any call to the host, the deployer checks the capability against the controller's store. If anything disagrees, the call is refused: in the design's own words, "the guard that makes a defect visible instead of effective".

There are two reasons to prefer fixed code to a careful agent here. Safety is the first: whatever reaches a deploy step has been reduced to data that a fixed program checks, and code does not change its mind when the input is persuasive. Reliability is the second. In one real system, the record notes that agents refused effectful or probe-like tasks inconsistently, so a step left to a model might be done one day and refused the next. A deterministic deployer does the same thing every time it is given the same inputs. How a person's approval of a release is tied to exactly what they were shown is a subject of its own.

One door for every model call

every model call passes one launch function, which attaches the controls build role run review role run chat turn one-shot, sandboxed calls launch function attaches, every time: role grant deadline budget receipt ledger row transcript one call model inside a governed run a direct call elsewhere bypassing the launch function repository check fails the build
Build runs, review runs and each chat turn all call the model through one launch function, which attaches role, grant, deadline, budget, receipt, ledger row and transcript before the call; a direct call that bypasses the launch function is failed by a repository check.

Limits and records are only as complete as the path they sit on. If a model can be called from two places and only one of them attaches a budget, the other is unbudgeted. So every model call goes through a single launch function, which attaches the role, the grant (what this run may use), a deadline, a budget, a receipt, a row in the usage ledger and the transcript. Interactive chat goes through it too, as one sandboxed one-shot run per turn. An automated check in the repository fails on any agent launch outside that function, so a second door cannot be added by accident. The arrangement works like a building with one staffed entrance, where every visitor signs the same book and gets a badge with an expiry time, so anyone found inside without a badge came in a way that should not exist.

Field recordIn one real system, before this rule, only headless runs wrote the usage ledger. Interactive sessions were, in the record's words, "the unmeasured half" of the cost picture: real model calls that left no row in the ledger. There were two ways in, and the accounting stood at only one of them.

The idea is older than language models. A classic 1975 paper on the design of protection systems calls it complete mediation: "Every access to every object must be checked for authority." A 1972 computer security planning study described the mechanism that does the checking, a reference monitor, with three requirements: it cannot be tampered with, it is always invoked, and it is small enough to be analyzed and tested completely. A single launch function aims at all three. The repository check is what makes it always invoked. Living in the controller, out of the agent's reach, is what protects it from tampering. And a function that does one job is small enough to read.

OWASP's 2025 guidance for applications built on language models uses the same term for the systems an agent calls: they should authorize every request themselves rather than leave the model to decide what is permitted. The launch function applies that rule one level up, to the model calls themselves.

Lifetimes and control flow belong in code

How long an agent lives, whether it can hand work to another agent, and whether it can schedule itself to run later are limits like any other, and they belong in structure, not in the prompt. A prompt that says "do not delegate" works like the difference between a sign reading staff only and a locked door: the sign works on people who read it and choose to obey, the lock works on everyone.

Field recordIn one real system, during a benchmark, a headless one-shot build agent called a sub-agent tool twice and a schedule-a-later-wakeup tool once, then ended its turn "waiting for the executor's completion notification". In one-shot mode there is no later turn. The run took eleven turns, 43 seconds and 465,000 tokens, and committed nothing. The first proposed fix was to drop the sub-agent tool from the runtime's list of allowed tools, and a probe disproved it: with a list of only two read-only tools, the sub-agent call still succeeded. That list, despite its name, only pre-approved tools that would otherwise ask permission; it did not limit which tools existed, and these tools never ask. An explicit deny flag produced "tool not available". Every headless launch now ends with a fixed deny list, and the configuration loader refuses any tool file that names a denied tool, including variants with different capitalization or names smuggled in with commas. The lesson recorded: removing a tool from such an allowlist "denies nothing".

Lifetime got the same treatment.

Field recordIn the same system, an executor reused across stages had reached 300,000 tokens of context by stage 27, and the fix was one stage per executor.

A scheduling bug showed why prompts are the wrong tool for control flow.

Field recordThe planner re-planned the same request on every scheduler tick, and planning consumed about 54% of the tokens in the run that was examined. The first response was to prompt the planner for a thinner backlog. Live validation did not solve it, and the record says the prompt fix made it worse. The cause was in the worker: the request stayed eligible, its priority outranked builds, and nothing checked whether stages already existed. What changed: the trigger is retired once planning succeeds, and a guard that checks for existing stages was added. The lesson recorded: "control-flow bugs need code fixes, not prompt fixes."

A fixed deny list has a weakness the record states openly: it can lag behind new tool and feature names. So the stronger rule is a true allowlist, enforced by the controller: it establishes which tools the agent actually has, from an inventory or from a test in which the agent is told to delegate and schedule and is seen to be unable to, refuses to launch without that evidence, and requires the available tools to be a subset of what was established. And a parent run's success never establishes that work it delegated has finished.

A limit is real only where you can stop

the controller can stop only at its stopping points, so usage can overshoot the budget usage time budget invocation 1 invocation 2 invocation 3 crosses the budget mid-invocation stop point: under, continue stop point: under, continue stop point: over, stop overshoot, bounded only by the deadline a deadline bounds the overshoot in time, not in tokens or money
Usage climbs through a run of invocations, but the controller can check and stop only at the boundary after each one, so usage can cross the budget partway through an invocation and keep climbing until the next stopping point; that overshoot is bounded only by the deadline, which limits time, not tokens or money.

Two questions decide whether a limit means anything: who may change it, and whether the controller can actually enforce it. The first already has a rule: never let the agent raise its own ceiling. Widening what agents or the controller may do is a person's decision. Settings are a closed schema that refuses unknown fields, and the controller computes the difference between the old settings and the new. A change that widens nothing is committed and recorded. A change that widens authority is never applied by a generic save: it raises an approval request, and whoever asked for it gets back "confirmation required". The settings that govern how checks run take a stricter route of their own.

The second question needs two separate facts kept apart: how often a backend reports its usage, and where the controller can actually stop it. Model APIs typically report token usage per response, and when a response streams, the count may arrive only at the end, spread across events, or not at all unless requested. If the controller can stop a run only between invocations, its budget check can only happen there, and one long invocation can carry usage past the line before the next check comes. So the enforceable boundaries are recorded for each backend, with the mechanism and how far usage can overshoot. At the whole-invocation boundary the overshoot is bounded only by the deadline, and the record says so. A deadline limits elapsed time, not tokens or money.

The rules follow from that. A budget policy that needs a stopping point the controller cannot enforce is refused before launch. A hard spending maximum is refused outright. A hard cap belongs at the provider, on a project or workspace that holds only the agent's dedicated key, and the controller records it as configured, never as something it enforces itself. That distinction is worth keeping: at the time of writing (2026), providers set such caps on an organization, project or workspace rather than on a single key, some offer only alerts, and at least one says enforcement can lag so that spend slightly exceeds the limit. Finally, no confirmation screen may label an estimate as a maximum. A displayed limit that is not one invites people to rely on it.

Tell the agent what the gate reads

A check is mechanical: it reads particular fields and compares them with particular rules. So an agent judged by a check can fail it for a reason that has nothing to do with the quality of its work, because nobody told it what the check reads. When that happens, the gap is in the controller's instructions, not in the agent's behavior, and that is where the fix belongs.

Field recordIn one real system, during a paid end-to-end run with a real coding agent, the agent writing the tests found a deliberately seeded defect correctly: a unit error in a session lifetime. But it left the optional field that says which check covers the finding empty, so the fix loop had nothing linking the finding to the required check, and that path of the run was recorded as "not established". The owner's decision was to fix the instructions first. Each role's briefing now lists every check in the current set: its name, the requirements it covers, the gates it applies to and whether it is required, but never its content. The briefing tells the test author to name each finding's check, and tells the agent fixing the defect that its finding is resolved when the named check passes. The rerun of that path passed, and the whole real-agent suite passed 16 of 16.

What keeps this honest over time is where the briefing text comes from. The block in each role's prompt that says what the gate reads is generated from the same constants the parser and the gate use, so when a field is added or renamed, the instructions change with it instead of drifting. The same holds for any agent judged by a machine. Telling the agent what is checked is not the same as letting it change the check: it learns the field names and the list, never the content, and the gate itself stays in code it cannot reach.

Trust the structure, not the agent

The capstone here is running a coding agent on real code without having to trust it, and this concept is the frame the rest hangs on. With every effect, privileged step and limit in controller code, a wrong or hijacked agent can still produce a bad proposal, but it cannot commit it itself, merge it, deploy it, extend its own run or mark its own work done. A run that breaks a rule ends as a rejected run, and a wrong change that keeps the rules still has to pass the checks and the approvals before it reaches the main branch.

In your own setup that comes down to a handful of decisions. The agent's process holds no version-control, tracker or deploy credential, and the controller does all the writing after the run, from an explicit list of effects that each have an owner. One function launches every model call, and a check in your repository keeps it the only one. Step, time and spend limits are counters in the controller, set to match where it can actually stop a run, and only a person widens them. The record of what is done changes only when the controller makes a transition. And each agent's briefing tells it what its gate reads, generated from the gate's own code.

None of this makes an agent safe by itself. It holds only as long as the agent really cannot reach the controller, and what the agent can still do through the network and the key it holds is a matter for the sandbox and for how its secrets are handled. It also moves the risk rather than removing it: the controller's code is now the part that has to be right, which is one more reason to keep it small. The neighboring pieces carry the rest: the sandbox that makes "cannot reach" true, the checks that decide what counts as done, the approvals that bind a person's decision to exactly what they saw, and the separation between the agents that build, test and review.

Sources

The published studies, standards and guidance this page cites. Links open on other sites. Field records come from the author's own records and have no public source.

  1. git-update-ref Documentation (Git) git-scm.com
  2. The Protection of Information in Computer Systems (Proceedings of the IEEE, 1975) web.mit.edu
  3. Computer Security Technology Planning Study, ESD-TR-73-51 Vol. I (James P. Anderson, USAF Electronic Systems Division, 1972) csrc.nist.gov
  4. LLM06:2025 Excessive Agency (OWASP Gen AI Security Project) genai.owasp.org

Next on your path to Run a coding agent you don't have to trust: