> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reliantlabs.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Have an agent address pull request review comments

> Let an agent act on review feedback: it changes the code, runs your checks, pushes to the pull request's own branch and replies in each review thread.

By the end of this guide, when you or someone you trust reviews a pull request you opted in, an agent changes the code to address the feedback, runs your fast checks, pushes a commit to that pull request's branch and replies in each review thread. A person still approves and merges.

This is `autopilot-review-responder`, one of the [Autopilot](https://docs.reliantlabs.io/guides/autopilot.md) built-ins. It works in a checkout, so it runs on a [machine](https://docs.reliantlabs.io/machines/overview.md) that holds a clone of the repository.

## Before you begin

* The `reliant` CLI, v1.21 or later, signed in ([Sign in and tokens](https://docs.reliantlabs.io/cli/sign-in.md)), and `gh` for the GitHub side.
* The Reliant GitHub App on the repository ([GitHub integration](https://docs.reliantlabs.io/integrations/github.md#access)), and a connected machine with a clone of it in a Reliant project. [Turn issues into pull requests](https://docs.reliantlabs.io/guides/workflows/github-issues-to-pull-requests.md) sets up the same project and machine.
* In an organization: an organization AI account that can run the `flagship` model, the responder's default.

**1. Turn on the review responder**

Run this in the clone. `--machine` takes the machine's hostname or daemon ID. `gate_command` is the check that must pass before anything is pushed; the default runs `gofmt` and your short test tier, so set it for your repository.

```bash terminal theme={null}
reliant trigger activate --workflow builtin://autopilot-review-responder \
  --machine build-box --project-id 9859294a-8b3c-419f-a5c4-eb85a022fd65 \
  --param 'repos=["reliant-labs/guides-sandbox"]' \
  --param 'gate_command=go test ./...' \
  --name-prefix "guides-sandbox-responder · review-responder"
```

```text theme={null}
TRIGGER           OUTCOME  ACTIVATION
review-submitted  enabled  guides-sandbox-responder · review-responder · review-submitted (339127e8-...)
review-comment    enabled  guides-sandbox-responder · review-responder · review-comment (43ac31df-...)
pr-comment        enabled  guides-sandbox-responder · review-responder · pr-comment (dc42945a-...)
```

The triggers wake it for a review, an inline comment and a pull request comment. In the app: **Workflows → Library → Autopilot · review responder → Set up**. Settings: [Autopilot settings](https://docs.reliantlabs.io/guides/autopilot.md#review-responder).

**2. Opt a pull request in**

The responder only touches pull requests carrying `agent:authored`, which the [issue worker](https://docs.reliantlabs.io/guides/workflows/github-issues-to-pull-requests.md) puts on the pull requests it opens, or `agent:respond`, which you add to any other:

```bash terminal theme={null}
gh pr edit 6 --add-label agent:respond
```

A pull request from a fork is never pushed to.

**3. Check whose feedback counts**

Feedback counts only from you, the accounts in `trusted_ids`, and [Autopilot PR review](https://docs.reliantlabs.io/guides/workflows/review-pull-requests-with-ai.md) when it has findings. To test that, save the `review-submitted` filter from the [workflow source](https://github.com/reliant-labs/reliant/blob/main/internal/workflow/builtin/autopilot-review-responder.yaml) as `filter.cel` and evaluate it against a sample event:

```bash terminal theme={null}
reliant workflow eval --integration github --event pull_request_review.submitted \
  --scope trigger --kind expression \
  --trigger-payload '{"attributes":{"repository":"acme/app","state":"changes_requested"},"data":{"pull_request":{"number":12,"labels":["agent:respond"]},"review":{"body":"Handle an empty slice in Average."}}}' \
  --trigger-sender '{"kind":"github","id":"583231","verified":true}' \
  --activation-params '{"repos":["acme/app"],"trusted_ids":[],"authored_label":"agent:authored","respond_label":"agent:respond"}' \
  --owner-github-id 583231 - < filter.cel
```

```text theme={null}
trigger.payload: generated from the payload github declares for pull_request_review.submitted, with your trigger_payload merged over it
true
  type: bool (read as expression)
```

The same event on a pull request labelled only `bug` prints `false`.

**4. Review the pull request**

Leave a review with a body, or comment on a line:

```bash terminal theme={null}
gh pr review 6 --comment -b "Add a test for a string shorter than n, so this case stays fixed."
reliant trigger events 339127e8-2be8-4f2c-b65c-3b41376e596d   # the review-submitted activation
```

The newest row should say `launched` with a chat ID. Follow it with `reliant workflow follow <chat>` or under **Workflows → Runs**.

**5. Read what it did**

On the pull request, look for:

* a lease comment and the `agent:working` label while the run holds the pull request;
* a commit on the pull request's branch, pushed only after `gate_command` passed (a run whose changes fail it twice pushes nothing);
* a reply in each inline thread, and one summary comment for the round;
* `agent:working` removed when the round ends.

Feedback that arrives during a round is picked up by another round. After `max_review_rounds` (3 by default) the pull request is labelled `agent:blocked` and left to you.

**6. Turn it off**

Pass `--project-id`, or `deactivate` pauses the workflow in every project you own:

```bash terminal theme={null}
reliant trigger deactivate --workflow builtin://autopilot-review-responder \
  --project-id 9859294a-8b3c-419f-a5c4-eb85a022fd65
```

## What this does not do

* **It never approves or merges.** No Autopilot workflow calls a merge. To merge from a workflow you compose that step yourself ([Merging is a workflow step](https://docs.reliantlabs.io/integrations/github.md#merging-is-a-workflow-step-never-an-agent-tool)).
* **It pushes only to the pull request's own branch.** Never to the default or a protected branch, never with `--force`. The agent's shell has no credentials.
* **It ignores strangers.** Feedback from anyone outside `trusted_ids` starts nothing and never reaches the agent.
* **It has no budget of its own.** Each round is up to 80 agent turns, three rounds per pull request, plus a retry. See [What it costs](https://docs.reliantlabs.io/guides/autopilot.md#what-it-costs).

## Troubleshooting

> [accordion] This automation runs only on its organization's AI accounts, and none of them can run the flagship model.
>
> `trigger events` shows the firing as `failed` with this detail and no chat: the event passed the filter, but the run could not start. An admin can add an organization API key or turn on Reliant credits, or set `--param 'model={"tags":["fast"]}'` to a model an organization account can run.

> [accordion] pr-comment failed: deadline exceeded
>
> Turning on all three triggers in one call can time out, and then none is enabled. Run the same command once per trigger, adding `--trigger review-submitted`, then `--trigger review-comment`, then `--trigger pr-comment`.

> [accordion] Nothing fires after a review
>
> Check that the pull request carries `agent:authored` or `agent:respond`, that the review has a body (an approval with no text is not feedback), and that it came from you or an account in `trusted_ids`.

## Next steps

> [card] [Review every pull request](https://docs.reliantlabs.io/guides/workflows/review-pull-requests-with-ai.md)
>
> The AI reviewer whose findings this workflow answers.

> [card] [Turn issues into pull requests](https://docs.reliantlabs.io/guides/workflows/github-issues-to-pull-requests.md)
>
> The issue worker opens the `agent:authored` pull requests.

> [card] [Autopilot reference](https://docs.reliantlabs.io/guides/autopilot.md)
>
> Labels, leases, settings and costs of every Autopilot workflow.

> [card] [Who an automation acts as](https://docs.reliantlabs.io/automations/overview.md#who-an-automation-acts-as)
>
> The Reliant bot, your own account, and the push check behind both.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.