Skip to content

Add autofix review loop for Copilot PRs#8181

Open
Evangelink wants to merge 2 commits into
mainfrom
dev/amauryleve/autofix-review-loop
Open

Add autofix review loop for Copilot PRs#8181
Evangelink wants to merge 2 commits into
mainfrom
dev/amauryleve/autofix-review-loop

Conversation

@Evangelink
Copy link
Copy Markdown
Member

Summary

Automates the review-fix cycle for Copilot-created PRs so maintainers only need to look at the final green PR.

The loop

PR opened ──► expert review (existing review-on-open)
                    │
            COMMENT or REQUEST_CHANGES
                    │
                    ▼
         address-review ──► reads ALL comments, assesses each one,
                            applies fixes or explains skip, pushes
                    │
               synchronize
                    │
                    ▼
         review-after-autofix ──► expert re-review
                    │
              ┌─────┴─────┐
          COMMENT     REQUEST_CHANGES
        (no issues)       │
              │      ▼ (loop back, max 3×)
              └──► done

New files

File Purpose
shared/address-review-shared.md Shared fix logic: classify comments (blocking/suggestion/informational) → apply fixes → build → push → summarize
address-review.agent.md Auto-trigger: fires on any non-approval pull_request_review for Copilot PRs or PRs labeled copilot-autofix
autofix.agent.md Manual trigger: /autofix slash command for maintainers to trigger on any PR
review-after-autofix.agent.md Re-review: fires on synchronize (push) for Copilot PRs, imports existing review-shared.md

Key design decisions

  • Assesses all comments: blocking → always fix; suggestions → apply if beneficial, explain if skipped; informational → acknowledge
  • Circuit breaker: counts <!-- autofix-iteration --> markers in PR comments, stops after 3 iterations
  • Scoping: auto-trigger limited to PRs by copilot-swe-agent[bot] or labeled copilot-autofix
  • Security: review-after-autofix uses pull_request (not pull_request_target) since Copilot PRs are same-repo only; checkout: false for review workflows
  • Reuses existing infra: re-review imports review-shared.md (same expert-reviewer), fix workflows import repo-build-setup.md

Three new gh-aw workflows that automate the review-fix cycle:

- address-review.agent.md: auto-triggered on any non-approval review
  for Copilot PRs (or PRs labeled copilot-autofix). Reads all review
  comments, classifies them (blocking/suggestion/informational), applies
  fixes or explains why a suggestion was skipped, builds, and pushes.

- autofix.agent.md: same behavior via /autofix slash command for
  maintainers to trigger on any PR.

- review-after-autofix.agent.md: re-runs expert review on synchronize
  (push) for Copilot PRs, closing the loop.

Circuit breaker: max 3 iterations tracked via HTML comment markers.
Shared body in shared/address-review-shared.md.
Copilot AI review requested due to automatic review settings May 13, 2026 12:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a four-piece agentic workflow loop that automatically addresses expert-reviewer feedback on Copilot-authored PRs and re-reviews the result, capped at 3 iterations. New .agent.md files (plus their auto-generated .lock.yml counterparts) share a single fix-logic body via shared/address-review-shared.md and reuse the existing review-shared.md for re-reviews.

Changes:

  • New shared fix-loop body (shared/address-review-shared.md) that classifies review comments, applies fixes, builds, and posts a summary with a <!-- autofix-iteration --> circuit-breaker marker.
  • Two trigger workflows: address-review.agent.md (auto-fires on non-approval pull_request_review for Copilot PRs) and autofix.agent.md (manual /autofix slash command).
  • review-after-autofix.agent.md re-runs the expert-reviewer on each synchronize to close the loop.
Show a summary per file
File Description
.github/workflows/shared/address-review-shared.md Shared address-review body: classify comments, apply fixes, build, push, summarize with circuit-breaker marker.
.github/workflows/address-review.agent.md Auto-trigger on pull_request_review for Copilot-authored / copilot-autofix PRs (non-approval, same-repo).
.github/workflows/autofix.agent.md Manual /autofix slash command (admin/maintainer/write roles) sharing the same fix logic.
.github/workflows/review-after-autofix.agent.md Re-runs expert reviewer on synchronize events; imports review-shared.md; checkout: false.
.github/workflows/*.lock.yml (4 files) Auto-generated lock files from gh aw compile; not hand-reviewed.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 3

Comment on lines +149 to +160
## Step 5 — Commit and Push

1. Stage all changed files.
2. Commit with a message in this format:

```
Address review feedback

Applied fixes for N review comments from the expert-reviewer.
```

3. Push to the PR branch.
3. **If the count is 3 or more**, post the following comment and then **stop immediately** — do not edit any files:

> ⚠️ **Autofix loop limit reached** (3 iterations). This PR needs human attention.
> <!-- autofix-iteration -->
Comment on lines +17 to +23
if: >-
github.event.review.state != 'approved'
&& github.event.pull_request.head.repo.id == github.repository_id
&& (
github.event.pull_request.user.login == 'copilot-swe-agent[bot]'
|| contains(github.event.pull_request.labels.*.name, 'copilot-autofix')
)
@Evangelink
Copy link
Copy Markdown
Member Author

@copilot address review comments

- Fix circuit breaker: use distinct <!-- autofix-limit-reached --> marker in the
  limit-reached comment so it isn't counted as an iteration
- Fix Step 5: instruct agent to use push_to_pull_request_branch safe output
  instead of direct git commands (credentials not available to agent)
- Narrow address-review trigger from != 'approved' to == 'changes_requested'
  so human COMMENT reviews don't spin up the full agent pipeline

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 13, 2026 14:27
@Evangelink Evangelink review requested due to automatic review settings May 13, 2026 14:27
Copy link
Copy Markdown
Contributor

Copilot AI commented May 13, 2026

@copilot address review comments

Addressed all three review comments in commit $(git rev-parse --short HEAD 2>/dev/null || echo "latest"):

  1. Trigger scope (address-review.agent.md:17-23): Changed != 'approved' to == 'changes_requested' so only explicit REQUEST_CHANGES reviews trigger the agent. Human informational COMMENT reviews no longer spin up the pipeline.

  2. Circuit-breaker duplicate marker (address-review-shared.md:63): The limit-reached comment now uses <!-- autofix-limit-reached --> instead of <!-- autofix-iteration -->, so it is never counted by the iteration counter and only one limit notice is ever posted.

  3. Step 5 git commands (address-review-shared.md:149-160): Replaced the git add / git commit / git push instructions with a directive to use the push_to_pull_request_branch safe output tool, which is the audited path that handles credentials and enforces protected_files checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants