fix(github_action): skip bot-sender comments to avoid feedback loop#2438
Open
IsmaelMartinez wants to merge 1 commit into
Open
fix(github_action): skip bot-sender comments to avoid feedback loop#2438IsmaelMartinez wants to merge 1 commit into
IsmaelMartinez wants to merge 1 commit into
Conversation
When run as a GitHub Action on issue_comment events, pr-agent re-fired on its own "Preparing review..." comments: each bot comment triggered another run that parsed the body as a command and failed with "Unknown command". Skip processing when the comment sender is a Bot, mirroring the documented `if: github.event.sender.type != 'Bot'` workflow guard so users no longer need it. Add regression tests for the bot-skip and that human comments are still handled. See The-PR-Agent#2398. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary by Qodo
Skip bot-authored GitHub Action comments to prevent issue_comment feedback loops
🐞 Bug fix🧪 Tests🕐 10-20 MinutesWalkthroughs
User Description
What
When pr-agent runs as a GitHub Action on
issue_commentevents, it re-fires on the comments it posts itself (e.g. "Preparing review..."). Each bot comment triggers anotherissue_commentrun, which parses the comment body as a command and fails withUnknown command: preparing, as described in #2398.Fix
Skip processing in the
issue_comment/pull_request_review_commenthandler when the comment's sender is a Bot. This mirrors theif: github.event.sender.type != 'Bot'guard the docs already recommend, so users no longer have to add it to every workflow themselves.Behaviour note: this skips all bot-authored comments. That matches the documented
sender.type != 'Bot'recommendation; if someone intentionally drives pr-agent from another bot, they'd need a different trigger. Happy to gate it behind a config flag instead if you'd prefer.Tests
test_issue_comment_from_bot_sender_is_skipped— a bot-authored comment is not handled.test_issue_comment_from_user_is_processed— a human comment is still handled (the guard doesn't over-skip).Fixes #2398.
AI Description
Diagram
graph TD A{{"GitHub comment event"}} --> B["github_action_runner.run_action"] --> C{"sender.type == Bot?"} C -- "yes" --> D["Log + return"] C -- "no" --> E["Parse body + URL"] --> F["PRAgent.handle_request"] --> G["GitHub API"] subgraph Legend direction LR _evt{{"Event"}} ~~~ _handler["Handler"] ~~~ _dec{"Decision"} endHigh-Level Assessment
The following are alternative approaches to this PR:
1. Workflow-level guard only (docs approach)
2. Config flag (e.g., skip_bot_senders=true by default)
3. Allowlist/denylist by sender.login (skip only pr-agent bot)
Recommendation: The current
sender.type == 'Bot'short-circuit is a solid default because it matches GitHub’s documented workflow guard and prevents a high-impact feedback loop out of the box. If there is a real use case for bot-driven commands, consider a follow-up that adds a config toggle or allowlist; otherwise keep the minimal guard for safety and simplicity.File Changes
Bug fix (1)
Tests (1)