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:
16
CLAUDE.md
16
CLAUDE.md
@@ -190,7 +190,7 @@ Workflows are located in `.gitea/workflows/` and are **mutually exclusive** to p
|
||||
|
||||
- **enterprise-ai-review.yml** - Triggered on PR open/sync
|
||||
- **ai-issue-triage.yml** - Triggered ONLY on `@codebot triage` in comments
|
||||
- **ai-comment-reply.yml** - Triggered on specific commands: `help`, `explain`, `suggest`, `security`, `summarize`, `review-again`, `setup-labels`
|
||||
- **ai-comment-reply.yml** - Triggered on specific commands: `help`, `explain`, `suggest`, `security`, `summarize`, `changelog`, `explain-diff`, `review-again`, `setup-labels`
|
||||
- **ai-chat.yml** - Triggered on `@codebot` mentions that are NOT specific commands (free-form questions)
|
||||
- **ai-codebase-review.yml** - Scheduled weekly analysis
|
||||
|
||||
@@ -201,6 +201,20 @@ Workflows are located in `.gitea/workflows/` and are **mutually exclusive** to p
|
||||
|
||||
This prevents the issue where all three workflows would trigger on every `@codebot` mention, causing massive duplication.
|
||||
|
||||
**CRITICAL: Bot Self-Trigger Prevention**
|
||||
|
||||
All workflows include `github.event.comment.user.login != 'Bartender'` to prevent infinite loops. Without this check:
|
||||
- Bot posts comment mentioning `@codebot`
|
||||
- Workflow triggers, bot posts another comment with `@codebot`
|
||||
- Triggers again infinitely → 10+ duplicate runs
|
||||
|
||||
**If you change the bot username**, update all three workflow files:
|
||||
- `.gitea/workflows/ai-comment-reply.yml`
|
||||
- `.gitea/workflows/ai-chat.yml`
|
||||
- `.gitea/workflows/ai-issue-triage.yml`
|
||||
|
||||
Look for: `github.event.comment.user.login != 'Bartender'` and replace `'Bartender'` with your bot's username.
|
||||
|
||||
**Note**: Issue triage is now **opt-in** via `@codebot triage` command, not automatic on issue creation.
|
||||
|
||||
Key workflow pattern:
|
||||
|
||||
Reference in New Issue
Block a user