Review pull requests with an agent
The Pull Request Reviewer template gives you an agent that reviews each pull request when it opens, but on its own it only sees the event, not the code. It reads the diff only if you give it a tool that can, or send the diff yourself. This page shows what to prepare, what each platform can supply, and how to roll the agent out without letting it write to your repositories on day one.
Enterprise module
The trigger and the connector tools need the enterprise Connectors module. See Connectors.
When to use
- You want a first review on every pull request that a human then reads and forwards.
- You use GitHub and want the shortest path. The template is built for it.
- You use Azure DevOps, GitLab or Bitbucket and need to know what the agent can and cannot see.
What the template does and does not do
| It does | It does not |
|---|---|
Reviews against a checklist skill, tpl-code-review-checklist, with the focus you set in the focus variable (default correctness, security, tests) | Come with any tool. The agent has no tools attached |
Returns structured output: summary, risk, up to 10 findings (file, line, severity, category, comment), tests_suggested, verdict and missing_context | Receive the diff in the event. The event carries the number, title, description, branches, author and link |
Sets the verdict to approve, comment, request_changes or needs_more_context | Invent findings. With no visible diff it returns an empty list, the verdict needs_more_context and says what it needs |
| Treats titles, descriptions, commit messages and code comments as data, not as instructions | Run code, so it never claims that tests passed |
Comes with a suggested GitHub pull_request trigger for opened, reopened, updated and ready-for-review events, skipping drafts | Post anything. Its answer is a JSON result until you add a tool or a callback |
The trigger is created disabled. The template suggests a reasoning-class model.
Decide: how the agent gets the diff
| Platform | Trigger for the agent | Read tools | Diff | Comment tool (write, Read only off) |
|---|---|---|---|---|
| GitHub | pull_request: the template's own | get_pull_request, list_pull_request_files | Yes. A patch per file, cut at 4,000 characters, and missing for binary or huge files. At most 3,000 files are listed | comment_on_pr: a comment in the conversation, not a line comment |
| Azure DevOps | pull_request_created, pull_request_updated | get_pull_request | No. It returns title, description, status, branches, merge status, reviewers' votes and labels | comment_on_pull_request: a new thread |
| GitLab | merge_request | get_merge_request | No. It returns the description, reviewers, merge status, the number of changed files and the latest pipeline status | comment_on_merge_request |
| Bitbucket (Cloud and Data Center) | None | get_pull_request | No. It returns the changed files (up to 50), lines added and removed on Cloud, and the comments. Read file content with get_file on the source branch | add_pull_request_comment |
The template's suggested trigger is for GitHub only. On another platform add your own connector trigger from the agent's Triggers tab and write the prompt against that package's event data.
Where the connector cannot read the diff, run the review from a pipeline step that has the diff and sends it to the agent. See GitHub Actions and Azure DevOps.
Prerequisites
| Check | Where | How to know |
|---|---|---|
| The Connectors module is in your package | Build → Connectors opens | Without it the agent is created without the connector trigger, and the result screen says so |
| A connector with a connected account, in the same project | Build → Connectors | The connector shows a connected account and its tool is Active |
The repository, as owner/name | The trigger's Repository field | The list reads from the connector, or you type it |
| The account may register a webhook | The connector's account | A trigger with an Active subscription. Otherwise it shows Needs setup with a callback URL and a secret for a manual setup |
GitHub can reach /api/public/connector-hooks/ on your address | APP_URL and your ingress | The subscription is not unreachable. An on-premises installation must route that path from the internet |
| Write actions are off until you want them | The connector's Read only setting, on by default | The comment tool is not offered while it is on |
| The trigger is enabled | The trigger's switch | It is created disabled. Enable it after you checked the subscription |
Steps
- Open Build → Agents → Templates and select Pull Request Reviewer. In Use template pick a chat model, pick your GitHub connector and type the Repository. Leave Create the suggested triggers on.
- Open the agent and its Build tab. In Tools choose Add → Add from hub / library…, expand the GitHub tool (it has the Connector badge) and tick
get_pull_requestandlist_pull_request_files. Leave the comment tool out for now. - Open the agent's Triggers and look at Review pull requests: the connector, the repository, the events and the filter
payload.draft eq false. Open its Settings tab and check the subscription. - Use the Test tab: Preview with a sample event shows the message the agent would get.
- Publish the agent. A trigger runs the published version.
- Enable the trigger.
See Connector triggers for the subscription states and Connector tools and approvals for the tool binding.
Verify
| Check | How | You should see |
|---|---|---|
| The subscription | The trigger's Settings tab | Active. If Needs setup, a callback URL and a secret to enter at GitHub |
| The message | The Test tab, Preview | The rendered prompt with the pull request number and the repository filled in |
| A real event | Open a non-draft pull request in the test repository | An entry in Deliveries, then a run of the agent with trigger: connector |
| The diff was read | Open the run | A call to list_pull_request_files, and findings with file names and lines |
| Drafts are skipped | Open a draft pull request | No run starts, because the filter skips drafts. Marking it ready starts one |
| No diff, no invention | Remove the tool and rerun | An empty findings list, needs_more_context and a missing_context text |
Roll it out in three stages
| Stage | Agent can | Who acts | Move on when |
|---|---|---|---|
| 1. Read only | Read the pull request and its files. The connector stays on Read only. No comment tool | A person reads the run result, or a callback sends it to a URL of your choice | Your reviewers agree with the findings on the pull requests you chose to compare |
| 2. Comment with human approval | Also comment_on_pr, with Read only off on the connector | A person approves each comment | Approved comments are mostly posted unchanged |
| 3. Evaluation gate | The same, wider: more repositories, fewer approvals | An evaluation decides whether a change to the prompt, the model or the tools may ship | The suite passes at the threshold you set |
Stage 2 details. A write action asks before it runs by default. A trigger run has nobody to answer, so with the default When nobody can answer setting, Deny the tool call, the comment is refused and the run goes on. To let a person approve, set it to Pause and wait for approval in Studio in the agent's Approvals & questions. The comment then waits in the session until someone answers. See Approvals.
Stage 3 details. Build a dataset of past pull requests with the problems a good review must catch, and an evaluation suite with your agent as the target. Use assertion scorers on the structured output (jsonSchema, jsonPath, mustContain) and an LLM judge with a rubric for the quality of a comment. Run it on every change to the prompt, the model or the tools. An alert rule on evaluation_pass_rate tells you when it drops.
Common problems
| Symptom | Cause | Fix |
|---|---|---|
The verdict is always needs_more_context | The agent has no tool that reads the diff, or the platform returns none | Bind list_pull_request_files on GitHub. On other platforms send the diff from a pipeline |
| Nothing starts when a pull request opens | The trigger is still disabled, the subscription is not Active, the repository is wrong, or the filter skips drafts | Check the Settings tab and Deliveries. unreachable means APP_URL is not public |
| The trigger shows Needs setup | The account cannot register a webhook | Enter the callback URL and the secret at GitHub under Settings → Webhooks, or give the account the webhook permission |
| The agent was created without a trigger | No GitHub connector, no Connectors module or no repository | Add the connector, then add the trigger from the agent's Triggers tab |
| A comment is never posted | Read only is on, the call was denied because nobody can answer, or the account cannot write | See stage 2 |
| A large pull request is reviewed in part | A patch is cut at 4,000 characters per file and GitHub omits some | Narrow the focus, split the pull request, and read missing_context |
| A review runs on every push | pull_request.synchronize is one of the events | Remove it, or accept a review per push. Each push is a new run |
| Strangers can start reviews on a public repository | Anyone can open a pull request | Add a rule on payload.author |

