Auto-address PR reviews: respond, push fixes, resolve threads - #120
Conversation
Lets Claude automatically handle review feedback without an @claude mention. A submitted PR review now triggers the workflow when the reviewer is the Codex bot or a trusted human (OWNER/MEMBER/COLLABORATOR); approved/dismissed reviews are skipped. The @claude mention path is unchanged. - Broaden the job 'if:' with a second (no-mention) trigger branch, and guard against self-triggering via github.actor != 'claude[bot]'. - Add a per-PR concurrency group (cancel-in-progress) to bound the Claude<->reviewer feedback loop. - Set allowed_bots to the Codex bot so the action does not skip the bot-triggered run (it skips bot actors by default). - Extend the system prompt: enumerate unresolved review threads via GraphQL, fix valid findings, run tests, push, reply to each thread, and resolve ONLY the threads actually fixed (leave disputed ones open). Needs pull-requests: write (already granted) for resolveReviewThread. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0dd8af14ec
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Only auto-address reviews (the no-@claude path) on PRs opened by claude[bot]. Reviews on human-authored PRs no longer trigger an Opus run automatically; maintainers can still invoke Claude there with an @claude mention. This narrows scope and further bounds the Claude<->reviewer loop. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@claude address codex's review |
|
Claude finished @fishjojo's task in 5m 13s —— View job Addressing Codex's review
Codex's P1 is correct — confirmed in the action sourceI traced
So the intended no-mention auto-address path would silently no-op. (The actor check is fine: FixSet a Apply this to @@ jobs.claude.steps[Run Claude Code].with @@
- # NOTE: no `prompt:` input. Setting `prompt:` forces the action into
- # "agent mode", which runs headlessly and does NOT post a reply back to
- # the issue/PR. Omitting it selects "tag mode", which responds to the
- # @claude mention and manages a response comment automatically. The
- # behavioral guidance that used to live in `prompt:` is moved into
- # `--append-system-prompt` below so tag mode keeps it.
+ # PROMPT / MODE SELECTION.
+ # claude-code-action auto-detects "tag" vs "agent" mode:
+ # - tag mode (empty prompt + @claude mention): posts/updates a tracking
+ # comment and auto-fetches PR context. This is the @claude path.
+ # - agent mode (non-empty prompt): runs headlessly; the prepare step
+ # only proceeds when `prompt` is non-empty.
+ # A pull_request_review submitted WITHOUT an @claude mention matches
+ # neither the tag trigger (no mention) nor the agent trigger (empty
+ # prompt). With an empty prompt that run is SKIPPED — and even if it ran,
+ # agent mode would only see "Repository: owner/repo" with no PR/review
+ # context. So set a prompt ONLY for that no-mention auto-review case: it
+ # selects agent mode, lets the run proceed, and carries the PR number +
+ # task. Every other trigger yields '' -> tag mode, unchanged. The detailed
+ # thread-handling procedure stays in `--append-system-prompt` below and
+ # applies in both modes.
+ prompt: >-
+ ${{ (github.event_name == 'pull_request_review'
+ && !contains(github.event.review.body, '@claude'))
+ && format('A pull request review was submitted on PR #{0} of {1} without an @claude mention. Follow the review-handling procedure in your system prompt: enumerate the PR''s unresolved review threads with `gh api graphql`, fix the valid findings, run the relevant tests when you touch code, commit and push to the PR branch, reply to each thread you handled, resolve ONLY the threads you actually fixed, and post one summary comment of what you fixed and what you left open.', github.event.pull_request.number, github.repository)
+ || '' }}
+
#Notes
I can't commit changes under |
Codex P1 (verified against the claude-code-action@v1 source): a pull_request_review with no @claude mention and no prompt resolves to agent mode (detector.ts default), and the prepare step skips agent-mode runs when the prompt is empty (prepare.ts gates on a non-empty prompt). So the no-mention auto-address path silently no-opped. Set a conditional 'prompt' that is non-empty ONLY for the no-mention pull_request_review case. A non-empty prompt selects agent mode and makes checkContainsTrigger true (trigger.ts: prompt provided -> always trigger), so the run proceeds with the PR number + task in context. Every other trigger evaluates to '' -> tag mode, unchanged. The prompt also tells Claude to 'gh pr checkout' the PR branch first, since the run starts on the base branch in this event. The detailed thread-handling procedure remains in --append-system-prompt and applies in both modes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a5782d1b95
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Two follow-up findings on the auto-address-review path: 1. Body-only review feedback (P2): the auto prompt only told Claude to enumerate inline reviewThreads, so a COMMENTED/CHANGES_REQUESTED review whose feedback lives only in the top-level review body would be missed (the body is not a review thread, and agent mode does not auto-fetch the triggering review). Pass github.event.review.body into the prompt and instruct Claude to address it in addition to inline threads. 2. Over-broad concurrency (P2): the per-PR group with cancel-in-progress would cancel an in-flight @claude mention run whenever any later event hit the same PR/issue. Make the group conditional: a shared per-PR group ('claude-autoreview-<pr>') only for the auto-review path so a newer review supersedes the in-flight auto-run (the loop bound), and a unique group ('claude-mention-<id>') keyed by the triggering comment/review/issue id for mention runs so they always run to completion. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 99366cf9fa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex P2: the workflow-level concurrency group is evaluated before the job-level if, so an ineligible pull_request_review (approved/dismissed, untrusted reviewer, non-Claude PR, or an @claude mention) still mapped to the shared 'claude-autoreview-<pr>' group and, with cancel-in-progress, would cancel a legitimate in-flight auto-fix run before its own job was skipped. Duplicate the auto-path eligibility checks from the job 'if' into the group expression: only reviews the job would actually accept for the auto path share 'claude-autoreview-<pr>'; every other event gets a unique 'claude-solo-<id>' group and cancels nothing. Added a comment to keep the two predicates in sync. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
What this does
Lets Claude automatically respond to PR reviews, push fixes, and resolve the review threads it addressed — no
@claudemention required. Motivated by #119, where Codex's review (P1/P2 inline threads) went unhandled because the bot'sauthor_associationisNONEand it never mentions@claude.How it works
1. Auto-trigger on reviews (
claude.ymlif:)A submitted
pull_request_reviewnow triggers Claude when either:chatgpt-codex-connector[bot]), orOWNER/MEMBER/COLLABORATOR).approved/dismissedreviews are skipped. The existing@claudemention path (all four events, trusted authors only) is unchanged. Agithub.actor != 'claude[bot]'guard prevents self-triggering.2.
allowed_botsThe action skips bot-triggered runs by default, so the Codex bot is added to
allowed_bots(scoped, not'*') — otherwise the auto-run is silently skipped.3. Resolve threads
Thread resolution has no REST endpoint, so the system prompt instructs Claude to:
gh api graphql(reviewThreads),resolveReviewThreadGraphQL mutation only for threads it actually fixed — disputed/unfixable ones stay open with an explanation.This uses the already-granted
pull-requests: writepermission.4. Loop bounding
A per-PR
concurrencygroup withcancel-in-progresscollapses stacked runs (Claude pushes → Codex re-reviews → supersedes the prior run). Full convergence still relies on the reviewer settling; a maintainer can intervene.Security / cost notes
Verification
settingsJSON parse cleanly;if:parens/brackets balanced.chatgpt-codex-connector[bot](typeBot) via the reviews API.actionlintnot run (binary download blocked in this environment) — expression checked by hand.🤖 Generated with Claude Code