Skip to content

fix: claude ワークフローの bot 自己トリガーループを防止 - #642

Merged
keito4 merged 1 commit into
mainfrom
fix/claude-workflow-bot-loop
Mar 25, 2026
Merged

fix: claude ワークフローの bot 自己トリガーループを防止#642
keito4 merged 1 commit into
mainfrom
fix/claude-workflow-bot-loop

Conversation

@keito4

@keito4 keito4 commented Mar 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Claude Code Action の「working...」コメントが issue_comment イベントを再トリガーし、既存のワークフロー実行がキャンセルされる問題を修正
  • Bot フィルタ github.event.sender.type != 'Bot' を追加(全 Bot 一括除外)
  • concurrency group に comment.id / review.id を追加

Test plan

  • Bot のコメントでワークフローがトリガーされないことを確認
  • 人間の @claude メンションで正常に起動することを確認

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated internal CI/CD workflow configuration to improve automated bot detection and prevent unnecessary cancellations across multiple workflow triggers.

- bot フィルタ sender.type != 'Bot' を追加(全 bot 一括除外)
- concurrency group に comment.id/review.id を追加

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 25, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR updates two GitHub Actions workflows to improve bot filtering and concurrency management. The bot exclusion logic changes from checking specific bot actor names to using a generic sender type check. Additionally, the claude workflow's concurrency grouping is refined to include comment and review IDs for better granularity.

Changes

Cohort / File(s) Summary
Claude Code Review Workflow
.github/workflows/claude-code-review.yml
Bot exclusion condition generalized from filtering by specific actor names (dependabot[bot]) to checking sender type (github.event.sender.type != 'Bot').
Claude Workflow
.github/workflows/claude.yml
Concurrency grouping enhanced to include comment and review IDs alongside PR/issue numbers for finer-grained cancellation control. Bot exclusion condition similarly generalized from specific actor checks to sender type check.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

bug, size/S

Poem

🐰 Bot filters now dance with grace,
No hardcoded names in this place—
Generic checks sweep wide and far,
Concurrency keys shine like a star,
Workflows bloom, conflict-free! 🌸

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title in Japanese clearly describes the main fix: preventing bot self-trigger loops in Claude workflows, which directly aligns with the PR's primary objective of stopping Claude's 'working...' comments from re-triggering the workflow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/claude-workflow-bot-loop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14a9be3959

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

permissions: {}

concurrency:
<<<<<<< Updated upstream

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove unresolved conflict markers from workflow

This commit leaves Git conflict markers (for example <<<<<<< Updated upstream) in claude.yml, which makes the workflow file invalid YAML. In this state, GitHub Actions cannot parse the workflow, so the Claude Code automation will fail to trigger on all configured events until the markers are removed and one branch of the conflict is resolved.

Useful? React with 👍 / 👎.

@keito4 keito4 self-assigned this Mar 25, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/claude-code-review.yml (1)

123-123: Add bot guard to check-ci-status job to prevent wasted runner time.

Line 23 allows bot-triggered PRs to enter the CI polling loop, while line 123 skips claude-review for bots. This creates inefficient behavior where bot PRs consume 20 minutes of runner time before the workflow exits. Mirror the bot guard from line 123 to line 23 to skip check-ci-status entirely for bot-generated pull requests.

♻️ Proposed change
  check-ci-status:
-    if: github.event.pull_request.draft == false
+    if: github.event.pull_request.draft == false && github.event.sender.type != 'Bot'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/claude-code-review.yml at line 123, The check-ci-status
job's if condition currently allows bot-triggered PRs into the CI polling loop;
update the job-level if condition for the check-ci-status job (the line starting
with "if: github.event.pull_request.draft == false &&
needs.check-ci-status.outputs.ci_passed == 'true'") to include the same bot
guard used for claude-review by adding "&& github.event.sender.type != 'Bot'".
This ensures the check-ci-status job skips entirely for bot-generated pull
requests and prevents wasting runner time.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/claude.yml:
- Around line 16-31: The workflow contains unresolved git conflict markers
(<<<<<<<, =======, >>>>>>>) around the group declaration which breaks YAML
parsing; remove those markers and replace the simple group line with the
stashed-expanded version that builds the group key using the folded block (>-)
and includes the comment/review IDs, i.e. keep the group declaration that
references github.event.issue.number || github.event.pull_request.number ||
github.run_id and appends github.event.comment.id || github.event.review.id ||
github.run_id, preserving the indentation and folded-block syntax so the final
YAML has a single valid group: entry without any conflict markers.

---

Nitpick comments:
In @.github/workflows/claude-code-review.yml:
- Line 123: The check-ci-status job's if condition currently allows
bot-triggered PRs into the CI polling loop; update the job-level if condition
for the check-ci-status job (the line starting with "if:
github.event.pull_request.draft == false &&
needs.check-ci-status.outputs.ci_passed == 'true'") to include the same bot
guard used for claude-review by adding "&& github.event.sender.type != 'Bot'".
This ensures the check-ci-status job skips entirely for bot-generated pull
requests and prevents wasting runner time.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 236659a1-c402-49fa-b213-072d56aa813f

📥 Commits

Reviewing files that changed from the base of the PR and between 2f5e3f9 and 14a9be3.

📒 Files selected for processing (2)
  • .github/workflows/claude-code-review.yml
  • .github/workflows/claude.yml

Comment on lines +16 to +31
<<<<<<< Updated upstream
group: claude-${{ github.repository }}-${{ github.event.issue.number || github.event.pull_request.number || github.run_id }}
=======
# イベント種別 + トリガーのコメント/レビューIDを含めることで、
# 同一 PR/Issue 内でも異なるメンションが互いをキャンセルしない
group: >-
claude-${{ github.repository }}-${{
github.event.issue.number
|| github.event.pull_request.number
|| github.run_id
}}-${{
github.event.comment.id
|| github.event.review.id
|| github.run_id
}}
>>>>>>> Stashed changes

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n '^(<<<<<<<|=======|>>>>>>>)' .github/workflows/claude.yml

Repository: keito4/config

Length of output: 1772


Resolve merge-conflict markers to restore workflow validity.

The file contains unresolved merge-conflict markers at lines 16-31 and 38-44 that make the YAML invalid. YAMLlint cannot parse Line 17 due to the syntax errors introduced by these markers. Remove the markers and keep the stashed changes as shown below:

Suggested resolution
 concurrency:
-<<<<<<< Updated upstream
-  group: claude-${{ github.repository }}-${{ github.event.issue.number || github.event.pull_request.number || github.run_id }}
-=======
   # イベント種別 + トリガーのコメント/レビューIDを含めることで、
   # 同一 PR/Issue 内でも異なるメンションが互いをキャンセルしない
   group: >-
     claude-${{ github.repository }}-${{
       github.event.issue.number
       || github.event.pull_request.number
       || github.run_id
     }}-${{
       github.event.comment.id
       || github.event.review.id
       || github.run_id
     }}
->>>>>>> Stashed changes
   cancel-in-progress: false
   claude:
     # Bot 全般を除外(sender.type で判定するため、Bot 名のハードコードが不要)
     if: |
-<<<<<<< Updated upstream
-      github.actor != 'github-actions[bot]' &&
-      github.actor != 'dependabot[bot]' &&
-      github.actor != 'claude[bot]' &&
-=======
       github.event.sender.type != 'Bot' &&
->>>>>>> Stashed changes
       (
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<<<<<<< Updated upstream
group: claude-${{ github.repository }}-${{ github.event.issue.number || github.event.pull_request.number || github.run_id }}
=======
# イベント種別 + トリガーのコメント/レビューIDを含めることで、
# 同一 PR/Issue 内でも異なるメンションが互いをキャンセルしない
group: >-
claude-${{ github.repository }}-${{
github.event.issue.number
|| github.event.pull_request.number
|| github.run_id
}}-${{
github.event.comment.id
|| github.event.review.id
|| github.run_id
}}
>>>>>>> Stashed changes
concurrency:
# イベント種別 + トリガーのコメント/レビューIDを含めることで、
# 同一 PR/Issue 内でも異なるメンションが互いをキャンセルしない
group: >-
claude-${{ github.repository }}-${{
github.event.issue.number
|| github.event.pull_request.number
|| github.run_id
}}-${{
github.event.comment.id
|| github.event.review.id
|| github.run_id
}}
cancel-in-progress: false
🧰 Tools
🪛 YAMLlint (1.38.0)

[error] 17-17: syntax error: could not find expected ':'

(syntax)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/claude.yml around lines 16 - 31, The workflow contains
unresolved git conflict markers (<<<<<<<, =======, >>>>>>>) around the group
declaration which breaks YAML parsing; remove those markers and replace the
simple group line with the stashed-expanded version that builds the group key
using the folded block (>-) and includes the comment/review IDs, i.e. keep the
group declaration that references github.event.issue.number ||
github.event.pull_request.number || github.run_id and appends
github.event.comment.id || github.event.review.id || github.run_id, preserving
the indentation and folded-block syntax so the final YAML has a single valid
group: entry without any conflict markers.

@keito4
keito4 merged commit c0116f2 into main Mar 25, 2026
14 checks passed
@keito4
keito4 deleted the fix/claude-workflow-bot-loop branch March 25, 2026 07:45
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.107.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant