Skip to content

fix(github_action): skip bot-sender comments to avoid feedback loop#2438

Open
IsmaelMartinez wants to merge 1 commit into
The-PR-Agent:mainfrom
IsmaelMartinez:fix/github-action-skip-bot-comments
Open

fix(github_action): skip bot-sender comments to avoid feedback loop#2438
IsmaelMartinez wants to merge 1 commit into
The-PR-Agent:mainfrom
IsmaelMartinez:fix/github-action-skip-bot-comments

Conversation

@IsmaelMartinez

@IsmaelMartinez IsmaelMartinez commented Jun 9, 2026

Copy link
Copy Markdown

PR Summary by Qodo

Skip bot-authored GitHub Action comments to prevent issue_comment feedback loops
🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

Walkthroughs

User Description

What

When pr-agent runs as a GitHub Action on issue_comment events, it re-fires on the comments it posts itself (e.g. "Preparing review..."). Each bot comment triggers another issue_comment run, which parses the comment body as a command and fails with Unknown command: preparing, as described in #2398.

Fix

Skip processing in the issue_comment / pull_request_review_comment handler when the comment's sender is a Bot. This mirrors the if: 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
• Skip issue_comment processing when the comment sender is a GitHub Bot
• Prevent pr-agent from re-triggering on its own status comments and failing command parsing
• Add regression tests ensuring bot comments are skipped while human comments still run
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"}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Workflow-level guard only (docs approach)
  • ➕ Keeps library behavior unchanged
  • ➕ Allows users to decide whether other bots should be able to trigger pr-agent
  • ➖ Easy to miss; every workflow must remember to add it
  • ➖ Doesn’t help users already experiencing the loop until they change workflows
2. Config flag (e.g., skip_bot_senders=true by default)
  • ➕ Maintains safe default while allowing opt-out for bot-driven automations
  • ➕ Makes behavior explicit and discoverable in configuration
  • ➖ Adds configuration surface area and support burden
  • ➖ Requires documenting and threading config through the action runner
3. Allowlist/denylist by sender.login (skip only pr-agent bot)
  • ➕ Preserves ability to trigger from other bots
  • ➕ More targeted than sender.type == Bot
  • ➖ Brittle across installations/forks/renamed apps
  • ➖ Still risks loops if other bot comments trigger self-replies

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.

Grey Divider

File Changes

Bug fix (1)
github_action_runner.py Skip bot-authored comment events in GitHub Action runner +8/-0

Skip bot-authored comment events in GitHub Action runner

• Adds an early-return guard in the issue_comment / pull_request_review_comment handler when the event sender is a Bot. This prevents pr-agent from re-triggering on its own comments and entering a command-parsing feedback loop (issue #2398).

pr_agent/servers/github_action_runner.py


Tests (1)
test_github_action_runner_core.py Add regression tests for bot-sender skip behavior +83/-0

Add regression tests for bot-sender skip behavior

• Introduces fixtures/helpers to isolate global settings mutations and to stub dependencies for issue_comment handling. Adds async tests verifying bot-authored comments are skipped and human comments still invoke PRAgent handling.

tests/unittest/test_github_action_runner_core.py


Grey Divider

Qodo Logo

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>
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Qodo Logo

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitHub Action re-triggers on its own bot comments, causing feedback loop

1 participant