At BauGPT every pull request goes through a review agent before it can merge. We call it the PR gate. It checks out the branch, runs the tests, looks for problems, verifies each finding and then gives a verdict. After a few weeks of runs it had seen the same mistakes again and again, and it kept rediscovering facts about our codebase from scratch on every run. So we wanted it to remember.
That sounds like an easy win. It is also the fastest way I know to make a reviewer worse without noticing.
The trap in "learn from past runs"
A human reviewer who has read a module many times starts to skim it. Most of the time that is fine. Then the bug lands in exactly the part they stopped reading. An agent with memory has the same failure, only faster and with better excuses. If the memory says "this test is flaky, ignore it" or "that warning was already there", the agent will happily skip the check, and the record of why it skipped is a note it wrote itself.
The worst part is that the gate would look like it got better. Fewer findings, faster runs, fewer arguments with the author. Every metric we watched would improve while the gate got blind.
So before the gate was allowed to learn anything, we wrote down what learning is not allowed to do.
Learnings only add checks
The rule is short. A learning can add a check. It can never set a verdict, lower a severity or skip a phase.
Everything the gate remembers falls into a few kinds: facts about the codebase, failure patterns that keep showing up in the author's pull requests, and mechanics of the test environment. Each entry carries its source, a command to re-check it and a date. A learning without a way to re-check it is an opinion, and the gate does not keep opinions.
These rules from that change did most of the work:
- "It was already broken" is not a permanent pass. A pre-existing failure is proven again on develop on every run, and if it still fails there, we open a ticket for it rather than wave it through forever.
- Learnings go stale. Anything older than 30 days is re-verified or deleted.
- A false positive is written down as "verify X", never as "ignore X". The next run still looks. It just knows what to look for.
The same release fixed a smaller version of the same problem. The gate used to decide on its own that an issue was merged. Now it only marks it merged when GitHub says so. A reviewer that trusts its own memory over the source of truth is the bug we were trying to avoid.
The learnings themselves come from real reviews. After the gate reviewed a backend change, we added what it taught us: how to treat message data a client can write, how to check guard tests, how to handle the dispositions of automated review comments, and a label check for the worktree. Each of those is a new thing to look at. None of them is a reason to look at less.
Let memory add checks. Give every entry its origin, a way to test it again and the day it was written.
Let memory set a verdict, lower a severity or skip a phase.
Holes we found anyway
Rules on paper are not enough, because an agent will find the gap between what you meant and what you wrote. On a frontend pull request the gate's sign-off produced a finding with a severity nobody had defined. It was called "accepted", and that made-up word got the finding past the merge check. Now any severity outside the known list is a NO-GO.
That is the shape of most failures in a system like this. Nobody decided to skip a check. A value showed up that the code had no case for, and the default let it through. A reviewer that cannot show why it decided something cannot be trusted to have decided it.
A reviewer that cannot show why it decided something cannot be trusted to have decided it.
That is why the next step was a record of every decision, not more rules on paper.
Re-deciding the past with today's rules
Every verdict now writes a line to a decision record. It holds what the gate saw for that unit of work, the round, the fixes, the risk tags from triage, the verdicts, and a stamp that says exactly which version of the gate decided: the plugin version, the commit it was built from, a hash of the verdict scripts, and the rules and schema version.
With that record, a replay script can decide every recorded unit again with the rules we have today and list each verdict that would change, with the old and the new reason. When I tighten a rule, I no longer guess what it would have done. I see which past pull requests it would have blocked, and which ones it would have let through.
Replay alone would still let us fool ourselves, so it is scored against truth labels: what actually happened to each gated pull request after the gate, and whether a bug was found later. A fixed part of those pull requests sits in a holdout set that we do not look at while we tune the rules. If a rule change only looks good on the cases I tuned it on, the holdout says so.
Trying a cheaper model without risking a verdict
The same idea let us try a cheaper model on the gate. In shadow mode, a separate verifier runs the finding-verification step on the same inputs as the live one. It never reads the live verifier's output, writes its result to its own file, and nothing but a comparison script reads that file, so it can never change a verdict.
That is the pattern I would copy into any agent that reviews or approves work. Memory and new models are welcome, as long as they can only make the gate look harder, and every decision carries enough of a stamp to be replayed and scored later. An agent that learns its way into skipping checks will look like it is improving right up to the day it merges the bug.