Feature: Update PR comments rather than continuously adding
The current implementation caused Claude bot to keep adding more comments to the PR rather than editing the original comment if there is already one. This resulted in a very long PR page.
The proposed implementation is to edit the comment that the Claude bot has already created.
+1
Can you clarify what you mean here? The current behavior is set up to have Claude edit its own comment in place. What do you expect to be different?
We setup a PR summarizer workflow and it also adds rather than updating the original comment. Here's our simple workflow:
name: Pull Request Summary
on:
pull_request:
types: [opened, synchronize]
jobs:
code-review:
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
runs-on: ubuntu-latest
steps:
# Check out the code to allow git diff operations
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history for accurate diffs
- name: Run Code Review with Claude
id: code-review
uses: anthropics/claude-code-action@main
with:
# Define the review focus areas
direct_prompt: 'Summarize the changes in this pull request. Focus on the most important changes and the impact of the changes.'
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
timeout_minutes: '5'
Note we're using @main instead of @beta if that makes a difference
We are seeing the same issue (but using @beta, not @main). The documentation says that Claude updates it's own comments but that has not been the case, it adds a new comment every time. Would love to know how to get it to update the original comment instead if that's possible.
Can you clarify what you mean here? The current behavior is set up to have Claude edit its own comment in place. What do you expect to be different?
In our usecase, we let claude-code-actions to comment PR's feedback and walkthrough, and we invoke it's workflow when PR is opend and syncronized(=pushed new commit).
In our case, claude-code-actions will create new comment on each syncronized, and this behavior causes too many comments and a bit noisy...
Perhaps, I need some parameter to let claude-code-actions to handle it's job with the existing comment instead of creating new comment.
While waiting for a fix, I've added a simple job that run before Claude to remove old comments:
jobs:
delete-old-claude-comments:
# Currently, the claude-code-action does not support updating its own comments.
# https://github.com/anthropics/claude-code-action/issues/37
name: Delete old Claude comments
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Clean up old comments
uses: actions/github-script@v7
with:
script: |
const params = { issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo }
const comments = await github.rest.issues.listComments(params);
for (const comment of comments.data) {
if (comment.user.login === 'claude[bot]') {
await github.rest.issues.deleteComment({ ...params, comment_id: comment.id });
}
}
claude-review:
needs: delete-old-claude-comments
name: Run anthropics/claude-code-action@beta
# ...
@ericmatte great suggestion! Ended up doing the same.
@Shinyaigeek thanks, I didn't realize this was regarding the code review flow in particular. I think that makes this a bit more sensible.
If we had Claude post an actual PR review instead of just a comment, would you also feel like it's too noisy?
Ran a company-wide beta of the PR review workflow last week and it got noisy fast.
Posting an actual PR review would be great, (especially with true line comments!) because github takes care of marking old reviews outdated. Cursor's bug bot posts multiple comments, but marks the old comments outdated. This feels like a good middle ground: GH's comment edit history isn't made for looking at drastically different versions.
@ashwin-ant Sorry for late reply 🙇 As @dereklucas said, I feel it is a good middle ground to add PR review instead of comment!
More ideally, I believe the following would be beneficial:
- The ability to execute commands by editing existing comprehensive comments.
- Comments would only be made on the diff of newly added commits, taking into account previous Claude code comments (or reviews).
- Perhaps this could be resolved at the user-level prompt.
Update : For my use case, use_sticky_comment: true option works perfectly! Claude code is now able to update its own PR comment without needing me to setup anything else.
Ditto to @ericmatte . use_sticky_comment: true works for me to resolve this issue as well.
use_sticky_comment: true doesn't work anymore - the bot keeps adding new comments.
v1.0.13
When using use_sticky_comment: true I'm seeing the bot continue to add comments instead of updating. It is very noisy.
Same use_sticky_comment: true doesn't work as expected
Any update on this?
I spotted that the bot ID was not the one expected.
Debugged with a command below to my private repo.
gh api /repos/{owner}/{repo}/issues/{issue_number}/comments
"user": {
"login": "github-actions[bot]",
"id": 41898xxx,
Or have I set my workflow in a bad way?? This could be a clue to resolve this issue.
It's likely this could help my case https://github.com/anthropics/claude-code-action/pull/651
I spotted that the bot ID was not the one expected. Debugged with a command below to my private repo.
gh api /repos/{owner}/{repo}/issues/{issue_number}/comments"user": { "login": "github-actions[bot]", "id": 41898xxx,Or have I set my workflow in a bad way?? This could be a clue to resolve this issue.
It's likely this could help my case #651
Sorry, I resolved my issue. The configuration was wrong.
Giving the explicit github_token: ${ secrets.GITHUB_TOKEN }} caused the wrong comment authoer github actions instead of claude[bot] . Removing github_token worked.
But there was one notice. A PR removing github_token failed with 401 error below. But ignore this error and merge the PR. Once the new workflow config is set in a repo, Claude started reviewing on the following PRs.
App token exchange failed: 401 Unauthorized - Workflow validation failed. The workflow file must exist and have identical content to the version on the repository's default branch. If you're seeing this on a PR when you first add a code review workflow file to your repository, this is normal and you should ignore this error.
@Shinyaigeek thanks, I didn't realize this was regarding the code review flow in particular. I think that makes this a bit more sensible.
If we had Claude post an actual PR review instead of just a comment, would you also feel like it's too noisy?
@ashwin-ant I believe this is the right way to go. So people can respond and resolve as if they were facing a real PR review comment. So, is there a way to do this now?