fix: Prevent bot self-trigger infinite loops in all workflows
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 34s
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 34s
CRITICAL FIX: Bot was triggering itself causing 10+ duplicate runs Problem: - When bot posts comments containing @codebot (e.g., help responses, PR reviews) - Workflows trigger on those bot comments - Bot responds again with @codebot mention - Infinite loop → 10+ duplicate workflow runs → excessive API costs Solution: - Added github.event.comment.user.login != 'Bartender' to all workflow conditions - Prevents bot from reacting to its own comments - Bot username 'Bartender' is now hardcoded in workflows Changes: - .gitea/workflows/ai-comment-reply.yml: Added bot username check - .gitea/workflows/ai-chat.yml: Added bot username check - .gitea/workflows/ai-issue-triage.yml: Added bot username check - CLAUDE.md: Documented bot self-trigger prevention and username update instructions - README.md: Added Step 3 to bot customization with critical warning Impact: - Eliminates infinite loop scenarios - Prevents excessive API costs from duplicate runs - Workflows only trigger on human user comments Note: If bot username changes from 'Bartender', all three workflow files must be updated.
This commit is contained in:
@@ -17,7 +17,9 @@ jobs:
|
||||
ai-chat:
|
||||
# Only run if comment mentions the bot but NOT a specific command
|
||||
# This prevents duplicate runs with ai-comment-reply.yml and ai-issue-triage.yml
|
||||
# CRITICAL: Ignore bot's own comments to prevent infinite loops (bot username: Bartender)
|
||||
if: |
|
||||
github.event.comment.user.login != 'Bartender' &&
|
||||
contains(github.event.comment.body, '@codebot') &&
|
||||
!contains(github.event.comment.body, '@codebot triage') &&
|
||||
!contains(github.event.comment.body, '@codebot help') &&
|
||||
|
||||
@@ -17,7 +17,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
# Only run for specific commands (not free-form chat or triage)
|
||||
# This prevents duplicate runs with ai-chat.yml and ai-issue-triage.yml
|
||||
# CRITICAL: Ignore bot's own comments to prevent infinite loops (bot username: Bartender)
|
||||
if: |
|
||||
github.event.comment.user.login != 'Bartender' &&
|
||||
(contains(github.event.comment.body, '@codebot help') ||
|
||||
contains(github.event.comment.body, '@codebot explain') ||
|
||||
contains(github.event.comment.body, '@codebot suggest') ||
|
||||
|
||||
@@ -12,7 +12,10 @@ jobs:
|
||||
ai-triage:
|
||||
runs-on: ubuntu-latest
|
||||
# Only run if comment contains @codebot triage
|
||||
if: contains(github.event.comment.body, '@codebot triage')
|
||||
# CRITICAL: Ignore bot's own comments to prevent infinite loops (bot username: Bartender)
|
||||
if: |
|
||||
github.event.comment.user.login != 'Bartender' &&
|
||||
contains(github.event.comment.body, '@codebot triage')
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
|
||||
Reference in New Issue
Block a user