A second reviewer on every pull request
Since the summer, a lot of pull requests at work get a first review from an agent. It reads the change before any person does, and leaves one comment with what it found.
It is called the PR agent, which is not the most creative name. I built it on two things this blog has already covered: Semantic Graph and the LLM gateway.
I am going to write a few posts about it, like I did with the gateway. This one is the overview. The interesting parts, and the mistakes, come later.
What a reviewer cannot see
A diff shows what changed. It does not show what depends on it.
Change the signature of a method in a shared library and the diff looks fine. The service that breaks lives in another repository, and nobody opened that one during the review. It is the same question that started Semantic Graph: what breaks if we change this?
An LLM that reads only the diff has the same problem. It is good at the lines in front of it: a missing null check, a loop that never ends, a name that lies. It cannot see the caller in the other repository, because nobody gave it that caller.
The other things a good reviewer checks are not in the diff either. Does the change do what the ticket asked, with the tests our standards expect? Has this part of the code broken before?
Someone with a few years on the team knows some of that by heart. Most reviewers do not have the time to look up the rest.
What it does
When someone opens a pull request, the Git server sends a webhook. The agent fetches the details, the diff and the linked Jira ticket. Then it runs five checks in parallel, which I call gates.
| Gate | The question it answers |
|---|---|
| Jira acceptance criteria | Does the change do what the ticket asks? |
| Tech Radar | Does it add a technology or a version the company Tech Radar advises against? |
| Testing | Does it ship the tests our testing standards ask for? |
| Incident history | Has this part of the code caused incidents before? |
| Code review | What would a senior engineer flag, including the impact outside the diff? |
Each gate is its own conversation with the model, with its own prompt and its own tools. The gates do not wait for each other. If one fails or runs out of time, the others carry on, and the comment says which one did not finish.
The result is one comment on the pull request. At the top there is a table with every gate, its status and one line of summary. This example is invented, but the shape is the real one:
| Gate | Status | Summary |
|---|---|---|
| Jira AC compliance | 🟩 PASSED | The three acceptance criteria are covered |
| Tech Radar compliance | 🟩 PASSED | No new technologies |
| Test strategy alignment | 🟨 WARNING | The new retry path has no test |
| Incident history | 🟩 PASSED | No related incidents in this area |
| Code review | 🟨 WARNING | One blocking issue, and two callers in another repository |
Below the table, only the gates that found something get a section. A gate that passed is one line and nothing more.
The comment is not the only output. The code review gate also leaves comments on the lines of the diff, where the problem is. It does that only for problems that should block the merge, so a line comment always means “look at this before you merge”.
It does not review again on every push, because a review per commit is spam. To get a new one, you write /review in a comment. /review testing runs only that gate.
Where the context comes from
Everything the agent learns about the code outside the diff comes from Semantic Graph. Each gate asks only for what it needs.
- Code review starts with three investigations side by side. One follows the calls in the code, one the configuration, and one the database schema. A second pass turns what they found into line comments, and a last one writes the summary.
- Testing searches for the tests that already exist before it says that something is untested.
- Jira acceptance criteria checks the rest of the codebase too, because a criterion can be met by code that was already there.
- Incident history looks for past incidents linked to the code the change touches.
The questions go through the recipes. One call returns the callers, the callers of the callers and the entry points above them. The model gets structured answers, not files to read.
The incident history closes a loop. When an incident is resolved, another agent in the same service classifies it and puts it back in the graph. The next review that touches that code can see it.
I kept one rule from the start. Semantic Graph returns information, and the agent decides what matters. If an answer is wrong, it is wrong in one place, and the judgement lives in the other.
The model, through the gateway
Every model call goes through the gateway. Each gate has its own key, so the cost of each one shows up on its own line. The diff gets the same masking of personal data and secrets as any other request.
The model behind it today is Kimi K2.7. It has a few habits with tool calls that I will come back to.
A pull request is text that somebody else wrote, and the agent reads it with tools in hand. So the diff, the title and the ticket go into the prompt inside a block marked as untrusted input. If the text tries to close that block itself, the tag is broken before the model sees it.
The prompts live somewhere else
The prompts are not in the service’s code. They are skills in a shared toolkit, the same one our coding agents load. The service unpacks them at build time, pinned to a version.
So the review on a pull request and the review you run from Claude Code on your laptop use the same words. A better prompt reaches both with one release.
What it is made of
For the curious, the stack. Spring Boot on Java 25, with Spring AI for the model calls and the tools. The gates run on virtual threads.
Bitbucket Server and GitLab sit behind one interface, so a gate does not know which one it is talking to. It runs on Kubernetes, with its metrics in Prometheus and its dashboards in Grafana.
Webhooks become events in Postgres before any work starts. A restart or a deploy in the middle of a review does not lose it, and any replica can pick it up. Every gate run also leaves a row with the model, the tokens, the tool calls, the time and the outcome.
How to tell if it works
This is the part that is easiest to get wrong.
The obvious number is the merge rate, and it says almost nothing. A pull request the agent flags gets fixed and merged like any other. Almost nobody declines a pull request because a bot complained.
So I look at other things:
- Thumbs. Anyone can react to an agent comment with 👍 or 👎. A 👍 means the point was valid, and the share of 👍 is how good the comments are.
- Reactions at all. How many comments get any reaction. A great share of 👍 means little if three people voted.
- Revised after review. Whether the author pushed a commit after the review. It is the closest thing to “the agent made someone change their code”.
- Blockers. Whether a blocking finding was acted on, or merged untouched. Untouched means a false positive or an ignored warning, and there is no way to tell which.
- Size. Whether the comments get worse on big pull requests.
None of these counts the incidents that did not happen. Nobody can count those. They are signals, and I read them side by side.
There is one more, for the agent itself. A gate that reaches no verdict gets a footnote in the comment instead of a row, so the agent counts those apart. A gate that has gone quiet looks a lot like a gate with nothing to say.
What comes next
This post was the overview. Getting here was not a straight line.
The first version had something to say about everything. At one point the agent asked the same question in a loop. And a lot of the work was not in the review at all, but in finding out whether it helped.
It is also going to change shape. Today each gate is a model call with a handful of tools, or none. The next step is to move the review into the online sandboxes, where it runs as a full agent in its own microVM.
I will write about some of that: how it changed, what went wrong on the way, and where it goes next. And about what the numbers say, once there are enough of them.