fix: Prevent duplicate workflow runs on @codebot mentions
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 40s
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 40s
Critical fix for workflow routing that was causing 3x duplication on every @codebot mention. All three workflows (ai-chat, ai-comment-reply, ai-issue-triage) were triggering simultaneously. Changes: - ai-issue-triage.yml: Only runs on '@codebot triage' (unchanged, already specific) - ai-comment-reply.yml: Only runs on specific commands (help, explain, suggest, etc) - ai-chat.yml: Only runs on free-form questions (excludes all specific commands) Workflow routing logic: 1. '@codebot triage' → ai-issue-triage.yml ONLY 2. '@codebot <command>' → ai-comment-reply.yml ONLY 3. '@codebot <question>' → ai-chat.yml ONLY (fallback) This prevents the massive duplication issue where every @codebot mention triggered all three workflows simultaneously, causing 10+ redundant runs. Updated documentation in CLAUDE.md with workflow routing architecture.
This commit is contained in:
@@ -1,42 +1,57 @@
|
|||||||
name: AI Chat (Bartender)
|
name: AI Chat (Bartender)
|
||||||
|
|
||||||
|
# WORKFLOW ROUTING:
|
||||||
|
# This workflow handles FREE-FORM questions/chat (no specific command)
|
||||||
|
# Other workflows: ai-issue-triage.yml (@codebot triage), ai-comment-reply.yml (specific commands)
|
||||||
|
# This is the FALLBACK for any @codebot mention that isn't a known command
|
||||||
|
|
||||||
on:
|
on:
|
||||||
issue_comment:
|
issue_comment:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
|
||||||
# CUSTOMIZE YOUR BOT NAME:
|
# CUSTOMIZE YOUR BOT NAME:
|
||||||
# Change '@ai-bot' below to match your config.yml mention_prefix
|
# Change '@codebot' in all conditions below to match your config.yml mention_prefix
|
||||||
# Examples: '@bartender', '@uni', '@joey', '@codebot'
|
# Examples: '@bartender', '@uni', '@joey', '@codebot'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ai-chat:
|
ai-chat:
|
||||||
# Only run if comment mentions the bot
|
# Only run if comment mentions the bot but NOT a specific command
|
||||||
if: contains(github.event.comment.body, '@codebot') # <-- Change this to your bot name
|
# This prevents duplicate runs with ai-comment-reply.yml and ai-issue-triage.yml
|
||||||
runs-on: ubuntu-latest
|
if: |
|
||||||
steps:
|
contains(github.event.comment.body, '@codebot') &&
|
||||||
- uses: actions/checkout@v4
|
!contains(github.event.comment.body, '@codebot triage') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot help') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot explain') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot suggest') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot security') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot summarize') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot review-again') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot setup-labels')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
repository: Hiddenden/openrabbit
|
repository: Hiddenden/openrabbit
|
||||||
path: .ai-review
|
path: .ai-review
|
||||||
token: ${{ secrets.AI_REVIEW_TOKEN }}
|
token: ${{ secrets.AI_REVIEW_TOKEN }}
|
||||||
|
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "3.11"
|
python-version: "3.11"
|
||||||
|
|
||||||
- run: pip install requests pyyaml
|
- run: pip install requests pyyaml
|
||||||
|
|
||||||
- name: Run AI Chat
|
- name: Run AI Chat
|
||||||
env:
|
env:
|
||||||
AI_REVIEW_TOKEN: ${{ secrets.AI_REVIEW_TOKEN }}
|
AI_REVIEW_TOKEN: ${{ secrets.AI_REVIEW_TOKEN }}
|
||||||
AI_REVIEW_REPO: ${{ gitea.repository }}
|
AI_REVIEW_REPO: ${{ gitea.repository }}
|
||||||
AI_REVIEW_API_URL: https://git.hiddenden.cafe/api/v1
|
AI_REVIEW_API_URL: https://git.hiddenden.cafe/api/v1
|
||||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
|
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
|
||||||
OLLAMA_HOST: ${{ secrets.OLLAMA_HOST }}
|
OLLAMA_HOST: ${{ secrets.OLLAMA_HOST }}
|
||||||
SEARXNG_URL: ${{ secrets.SEARXNG_URL }}
|
SEARXNG_URL: ${{ secrets.SEARXNG_URL }}
|
||||||
run: |
|
run: |
|
||||||
cd .ai-review/tools/ai-review
|
cd .ai-review/tools/ai-review
|
||||||
python main.py comment ${{ gitea.repository }} ${{ gitea.event.issue.number }} "${{ gitea.event.comment.body }}"
|
python main.py comment ${{ gitea.repository }} ${{ gitea.event.issue.number }} "${{ gitea.event.comment.body }}"
|
||||||
|
|||||||
@@ -1,17 +1,30 @@
|
|||||||
name: AI Comment Reply
|
name: AI Comment Reply
|
||||||
|
|
||||||
|
# WORKFLOW ROUTING:
|
||||||
|
# This workflow handles SPECIFIC commands: help, explain, suggest, security, summarize, review-again, setup-labels
|
||||||
|
# Other workflows: ai-issue-triage.yml (@codebot triage), ai-chat.yml (free-form questions)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
issue_comment:
|
issue_comment:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
|
||||||
# CUSTOMIZE YOUR BOT NAME:
|
# CUSTOMIZE YOUR BOT NAME:
|
||||||
# Change '@ai-bot' below to match your config.yml mention_prefix
|
# Change '@codebot' in the 'if' condition below to match your config.yml mention_prefix
|
||||||
# Examples: '@bartender', '@uni', '@joey', '@codebot'
|
# Examples: '@bartender', '@uni', '@joey', '@codebot'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ai-reply:
|
ai-reply:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: contains(github.event.comment.body, '@codebot') # <-- Change this to your bot name
|
# Only run for specific commands (not free-form chat or triage)
|
||||||
|
# This prevents duplicate runs with ai-chat.yml and ai-issue-triage.yml
|
||||||
|
if: |
|
||||||
|
(contains(github.event.comment.body, '@codebot help') ||
|
||||||
|
contains(github.event.comment.body, '@codebot explain') ||
|
||||||
|
contains(github.event.comment.body, '@codebot suggest') ||
|
||||||
|
contains(github.event.comment.body, '@codebot security') ||
|
||||||
|
contains(github.event.comment.body, '@codebot summarize') ||
|
||||||
|
contains(github.event.comment.body, '@codebot review-again') ||
|
||||||
|
contains(github.event.comment.body, '@codebot setup-labels'))
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
name: AI Issue Triage
|
name: AI Issue Triage
|
||||||
|
|
||||||
|
# WORKFLOW ROUTING:
|
||||||
|
# This workflow handles ONLY the 'triage' command
|
||||||
|
# Other workflows: ai-comment-reply.yml (specific commands), ai-chat.yml (free-form questions)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
issue_comment:
|
issue_comment:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
|||||||
17
CLAUDE.md
17
CLAUDE.md
@@ -186,14 +186,21 @@ Optional:
|
|||||||
|
|
||||||
## Workflow Architecture
|
## Workflow Architecture
|
||||||
|
|
||||||
Workflows are located in `.gitea/workflows/`:
|
Workflows are located in `.gitea/workflows/` and are **mutually exclusive** to prevent duplicate runs:
|
||||||
|
|
||||||
- **ai-review.yml** / **enterprise-ai-review.yml** - Triggered on PR open/sync
|
- **enterprise-ai-review.yml** - Triggered on PR open/sync
|
||||||
- **ai-issue-triage.yml** - Triggered on `@codebot triage` mention in issue comments
|
- **ai-issue-triage.yml** - Triggered ONLY on `@codebot triage` in comments
|
||||||
- **ai-comment-reply.yml** - Triggered on issue comments with @bot mentions
|
- **ai-comment-reply.yml** - Triggered on specific commands: `help`, `explain`, `suggest`, `security`, `summarize`, `review-again`, `setup-labels`
|
||||||
- **ai-chat.yml** - Triggered on issue comments for chat (non-command mentions)
|
- **ai-chat.yml** - Triggered on `@codebot` mentions that are NOT specific commands (free-form questions)
|
||||||
- **ai-codebase-review.yml** - Scheduled weekly analysis
|
- **ai-codebase-review.yml** - Scheduled weekly analysis
|
||||||
|
|
||||||
|
**Workflow Routing Logic:**
|
||||||
|
1. If comment contains `@codebot triage` → ai-issue-triage.yml only
|
||||||
|
2. If comment contains specific command (e.g., `@codebot help`) → ai-comment-reply.yml only
|
||||||
|
3. If comment contains `@codebot <question>` (no command) → ai-chat.yml only
|
||||||
|
|
||||||
|
This prevents the issue where all three workflows would trigger on every `@codebot` mention, causing massive duplication.
|
||||||
|
|
||||||
**Note**: Issue triage is now **opt-in** via `@codebot triage` command, not automatic on issue creation.
|
**Note**: Issue triage is now **opt-in** via `@codebot triage` command, not automatic on issue creation.
|
||||||
|
|
||||||
Key workflow pattern:
|
Key workflow pattern:
|
||||||
|
|||||||
Reference in New Issue
Block a user