Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/review-responder.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions .github/workflows/review-responder.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ permissions:
issues: read
pull-requests: read

imports:
- shared/fetch-review-comments.md

checkout:
fetch: ["*"]
fetch-depth: 0
Expand Down Expand Up @@ -57,13 +60,13 @@ This workflow addresses unresolved review comments on a pull request.

2. Add the label `aw-review-response-attempted` to the PR.

3. Read the unresolved review comment threads on the PR using the GitHub REST API: fetch `https://api.github.com/repos/$OWNER/$REPO/pulls/$PR_NUMBER/comments` and `https://api.github.com/repos/$OWNER/$REPO/pulls/$PR_NUMBER/reviews`. If there are more than 10 unresolved threads, address the first 10 and leave a summary comment on the PR noting how many remain for manual follow-up.
3. Read the pre-fetched unresolved review threads from the file `/tmp/gh-aw/review-data/unresolved-threads.json`. This file was populated before you started by a workflow step that queried the GitHub GraphQL API. Each thread contains an `id`, `comments` array (with `databaseId`, `body`, `path`, `line`, `author`), and resolution status. If the file is empty or contains `[]`, there are no unresolved threads — stop and report via noop. If there are more than 10 unresolved threads, address the first 10 and leave a summary comment on the PR noting how many remain for manual follow-up.

4. For each unresolved review comment thread (up to 10):
a. Read the comment and understand what change is being requested
b. Read the relevant file and surrounding code context
c. Make the requested fix in the code
d. Reply to the comment thread explaining what you changed
d. Reply to the comment thread using `reply_to_pull_request_review_comment` with the comment's `databaseId` as the `comment_id`

5. After addressing all comments, run the CI checks locally to make sure your fixes don't break anything: `uv sync && uv run ruff check --fix . && uv run ruff format . && uv run pyright && uv run pytest --cov --cov-fail-under=80 -v`

Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/shared/fetch-review-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
steps:
- name: Fetch PR review comments
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ inputs.pr_number }}
run: |
mkdir -p /tmp/gh-aw/review-data

OWNER="${GITHUB_REPOSITORY_OWNER}"
REPO="${GITHUB_REPOSITORY#*/}"

echo "Fetching review comments for PR #${PR_NUMBER}..."

# Fetch review comment threads via GraphQL (includes resolution status)
gh api graphql -f query='
query($owner: String!, $repo: String!, $pr: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pr) {
title
body
reviewThreads(first: 100) {
nodes {
id
isResolved
isOutdated
comments(first: 100) {
nodes {
id
databaseId
body
path
line
author { login }
createdAt
}
}
}
}
}
}
}' -f owner="$OWNER" -f repo="$REPO" -F pr="$PR_NUMBER" \
> /tmp/gh-aw/review-data/threads.json

# Extract unresolved threads for easy agent consumption
if ! jq '[.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false) | .comments = .comments.nodes]' \
/tmp/gh-aw/review-data/threads.json \
> /tmp/gh-aw/review-data/unresolved-threads.json; then
echo "Error: Failed to extract unresolved review threads from GraphQL response" >&2
exit 1
fi

UNRESOLVED=$(jq 'length' /tmp/gh-aw/review-data/unresolved-threads.json)
echo "Found ${UNRESOLVED} unresolved thread(s)"
echo "Data saved to /tmp/gh-aw/review-data/"
---

<!--
## Fetch PR Review Comments

Shared component that pre-fetches PR review comment threads before the agent runs.
The agent reads `/tmp/gh-aw/review-data/unresolved-threads.json` instead of using MCP tools.

### Why

The GitHub MCP `pull_request_read` tool intermittently returns empty arrays `[]` inside
the gh-aw agent sandbox. This has been observed consistently in our repo — the tool
never reliably returns review comment data. Pre-fetching via `gh api` in a workflow step
(which has GITHUB_TOKEN) bypasses the MCP entirely.

### Output Files

- `/tmp/gh-aw/review-data/threads.json` — Full GraphQL response with all review threads
- `/tmp/gh-aw/review-data/unresolved-threads.json` — Filtered to unresolved threads only

### Usage

Import in your workflow:

```yaml
imports:
- shared/fetch-review-comments.md
```

Then tell the agent to read the pre-fetched data:

```markdown
Read the unresolved review threads from `/tmp/gh-aw/review-data/unresolved-threads.json`.
```
-->
Loading