diff --git a/.gitea/workflows/ai-chat.yml b/.gitea/workflows/ai-chat.yml index ea2ad47..19b7918 100644 --- a/.gitea/workflows/ai-chat.yml +++ b/.gitea/workflows/ai-chat.yml @@ -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') && diff --git a/.gitea/workflows/ai-comment-reply.yml b/.gitea/workflows/ai-comment-reply.yml index 25707b7..dc469fe 100644 --- a/.gitea/workflows/ai-comment-reply.yml +++ b/.gitea/workflows/ai-comment-reply.yml @@ -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') || diff --git a/.gitea/workflows/ai-issue-triage.yml b/.gitea/workflows/ai-issue-triage.yml index 48a10ed..bb9ad80 100644 --- a/.gitea/workflows/ai-issue-triage.yml +++ b/.gitea/workflows/ai-issue-triage.yml @@ -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 diff --git a/CLAUDE.md b/CLAUDE.md index 7f63769..a3275a4 100644 --- a/CLAUDE.md +++ b/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: diff --git a/README.md b/README.md index b81bb5a..2707c29 100644 --- a/README.md +++ b/README.md @@ -479,6 +479,15 @@ if: contains(github.event.comment.body, '@codebot') Change `@codebot` to your new bot name. +**Step 3 (CRITICAL):** Update bot username to prevent infinite loops: + +In all three workflow files, find: +```yaml +github.event.comment.user.login != 'Bartender' +``` + +Replace `'Bartender'` with your bot's Gitea username. This prevents the bot from triggering itself when it posts comments containing `@codebot`, which would cause infinite loops and 10+ duplicate workflow runs. + --- ## Security Scanning