AI agent guardrails: turning written rules into checks that run first
By Otto van der Schaaf, We-Amp ·
In July 2026 we counted the corrections we had written down for our AI agents. Each one recorded a time an agent got something wrong and we wrote a rule so it would not happen again. There were 77. Only 5 were enforced by a real check, 10 were partly enforced, and 62 existed only as written instructions, so an agent had to remember each one at the moment it mattered.
That count changed how we think about agent safety. The failure we kept seeing was a rule that was written down, read at the start of a session and not applied two hours later. This post covers how we moved the risky rules into checks that run before the action, how we keep those checks from quietly breaking, and what stays with a person.
AI agents run our release train covered the gates around our releases. This post covers the rest of the company’s agent work.
Contents
- Why do written agent guardrails fail?
- Which rules mattered most?
- What does a guardrail check look like?
- Who checks the checks?
- What is a model’s review for?
- What went wrong?
- What stays with a person?
- Turning your own rules into checks
Why do written agent guardrails fail?
An instruction file works like a briefing. It is read once, at the start, and then it competes with everything else in the session: the task, the error messages, the last thing a tool printed. A rule that matters only once in a long session is the one most likely to be missed, because nothing in the moment points at it.
Our own record showed this. Of the 62 corrections that existed only as prose, 11 had come up again and again, and 30 more had come up more than once. Writing a rule down a second time did not stop the third.
Which rules mattered most?
We sorted every action by two questions, the same ones as in the release-train post: can it be undone, and can a script check the result before it happens?
Four classes of action were both irreversible and protected only by prose:
- production deploys;
- money and bookkeeping;
- product releases;
- public text: posts, release notes, pull request descriptions and comments.
Those came first. Reversible work, such as a merge that a revert undoes, could stay on written rules plus review for longer, because a mistake there costs a revert.
What does a guardrail check look like?
Each check runs before the agent’s action, not after it. In a coding agent this is a pre-action hook: it reads the command or the file the agent is about to write, and refuses it if it breaks a rule. A refusal tells the agent why, so it can take another route. Some of what our checks refuse:
- Printing a secret. A command that would show the contents of a credentials file is refused.
- Changing a primary checkout. Agent work happens in separate working copies. A write, or a command that would change files, in a primary checkout is refused.
- Merging or queueing a pull request from a fork. Only the owner does that, after reading the full diff.
- Sending a message to a customer. An agent drafts it, and a person sends it.
- Text that must not go public. Public text is checked before it is posted for a short list of things that must never appear in it.
In each case the check sits in the path of the action, so the rule no longer depends on the agent remembering it.
The same idea applies to agents that do not write code. Our benchmarking agent drives a load generator and a proxy on a test machine, and it may not decide anything: every number it produces is labelled as steering only, and a pre-registered run decides. Envoy benchmarking with an extended Nighthawk describes it.
Who checks the checks?
A check that is switched off, or broken by an edit, protects nothing and looks the same as one that works. So the checks have their own checks:
- The check files are pinned. Their contents are recorded, and a change to any of them fails an automated check until it is deliberately recorded. Such a change goes through the same review as any other change, and the owner approves it.
- Their settings are tested. A test fails if a blocking check is not set to refuse when it cannot finish, or if a check is not wired up at all.
- They fail closed. If a blocking check cannot run, the action is refused, not allowed.
Failing closed has a cost, and we paid it once (below). We still prefer a session that cannot do anything over a session that can do anything.
What is a model’s review for?
AI agents also review each other’s work, through multiple independent lenses using top-tier models. Those reviews find real problems, and they find them early. They are also inconsistent: two runs of the same review can disagree, and a review can miss what the next one finds.
So a model’s review can raise a problem but never clears a gate. If a review flags something, the change stops. If every review passes, the change still has to pass the checks, and an irreversible step still needs a person. A rule that only a review enforces counts as prose in our sorting.
What went wrong?
The checks have failed too. Each failure changed a check.
- A command overwrote work in a primary checkout. The check against changing primary checkouts covered file writes, and an agent ran a command that replaced a checkout’s files with those of another branch. That kind of command is now refused too.
- One change of directory stopped every session. Our checks were wired up in a way that depended on the agent’s current directory. After an agent changed directory, none of the checks could start, and because the blocking ones fail closed, the session could run nothing at all. The wiring no longer depends on the directory, and a test fails if it ever does again.
- Two agents shared a scratch file. Two agents working in parallel wrote their pull request descriptions to the same file, and one of them posted the other’s internal description on a public pull request. Each agent now writes to a file named for it.
What stays with a person?
Some decisions are not given to a check or an agent, by design:
- Meaning. Whether a sentence gives away something it should not is judged by a person before public text goes out.
- Taste and priorities. Whether a change is the right one, or a post says the right thing, is a human call.
- Decisions in the owner’s name. Prices, releases, spending, legal matters and anything said to a customer stay with a person by written rule.
- New rules. A check exists because a rule existed first, usually because something went wrong once. Deciding what the next rule is stays with a person.
We-Amp is one person working with AI agents, with about ten months of record on this setup. We have not tried it on a large team; the four steps below are where we would start with one.
Turning your own rules into checks
The work fits in four steps:
- Collect every rule your agents are expected to follow, from instruction files, review comments and the chat history where you corrected them.
- Mark each one: is it enforced by a check, partly, or only by prose?
- For each action that cannot be undone, make sure a check or a named person stands in front of it. Start there.
- Put the checks themselves under a check, and make them fail closed.
The second step is usually the surprise. It is also where we start when we work with a team.