Files
openrabbit/.gitea/workflows/ai-chat.yml
latte 8afad737ba
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 34s
fix: Prevent bot self-trigger infinite loops in all workflows
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.
2025-12-29 13:12:19 +00:00

62 lines
2.7 KiB
YAML

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:
issue_comment:
types: [created]
# CUSTOMIZE YOUR BOT NAME:
# Change '@codebot' in all conditions below to match your config.yml mention_prefix
# Examples: '@bartender', '@uni', '@joey', '@codebot'
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') &&
!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 changelog') &&
!contains(github.event.comment.body, '@codebot explain-diff') &&
!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
with:
repository: Hiddenden/openrabbit
path: .ai-review
token: ${{ secrets.AI_REVIEW_TOKEN }}
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install requests pyyaml
- name: Run AI Chat
env:
AI_REVIEW_TOKEN: ${{ secrets.AI_REVIEW_TOKEN }}
AI_REVIEW_REPO: ${{ gitea.repository }}
AI_REVIEW_API_URL: https://git.hiddenden.cafe/api/v1
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
OLLAMA_HOST: ${{ secrets.OLLAMA_HOST }}
SEARXNG_URL: ${{ secrets.SEARXNG_URL }}
run: |
cd .ai-review/tools/ai-review
python main.py comment ${{ gitea.repository }} ${{ gitea.event.issue.number }} "${{ gitea.event.comment.body }}"