Skip to content

fix: reliably trigger review chain when Claude bot opens PRs (pull_request opened missed) #2251

Description

@MervinPraison

Summary

When praisonai-triage-agent[bot] opens a PR via claude.yml (gh pr create), the pull_request: opened event sometimes does not trigger downstream GitHub Actions. The full review chain (CodeRabbit → Copilot → FINAL @claude) never starts.

Example: PR #2245 — opened 2026-06-24 13:34:57 alongside #2243 and #2244 within ~11 seconds. #2243/#2244 got Auto PR Comment + full chain; #2245 got zero pull_request workflow runs and only a Greptile comment.

Manual unblock applied: FINAL @claude comment posted on #2245#2245 (comment)


Root cause

flowchart TD
  A[claude.yml creates PR via App token / GITHUB_TOKEN] --> B{pull_request opened fires?}
  B -->|Yes| C[bot-pr-trigger-reviews in auto-pr-comment.yml]
  C --> D["@coderabbitai + /review as MervinPraison PAT"]
  D --> E["@copilot → FINAL @claude"]
  B -->|No / dropped in burst| F[No workflows run]
  F --> G[Only external apps e.g. Greptile comment]
  G --> H[No @claude ever posted]
Loading

Contributing factors:

  1. GitHub limitation: Events triggered by GITHUB_TOKEN (including GitHub App tokens used by claude-code-action for gh pr create) may not trigger new workflow runs on pull_request: opened.
  2. Burst bot PR creation: When multiple bot PRs open within seconds, GitHub can drop/suppress events for later PRs in the batch (observed: 3rd PR in burst missed all workflows).
  3. No fallback in claude.yml: After gh pr create, nothing uses GH_TOKEN PAT to kick the review chain.
  4. Greptile is not wired into chain: auto-pr-comment.yml only chains off CodeRabbit/Qodo/Copilot — not Greptile alone.

Affected workflow: .github/workflows/auto-pr-comment.yml job bot-pr-trigger-reviews (requires pull_request: opened).


Required changes

1. Post-PR-create hook in claude.yml (primary fix)

After Claude runs gh pr create for issue fixes, add a final workflow step (only when a new PR was created) that uses secrets.GH_TOKEN (PAT as MervinPraison) to:

- name: Kick review chain for bot-created PR
  if: steps.check_fork.outputs.is_pr != 'true'  # issue flow that created PR
  env:
    GH_TOKEN: ${{ secrets.GH_TOKEN }}
  run: |
    PR_NUM=$(gh pr list --head "$BRANCH" --json number -q '.[0].number')
    # Same as bot-pr-trigger-reviews
    gh pr comment "$PR_NUM" --body '@coderabbitai review'
    gh pr comment "$PR_NUM" --body '/review'

Or consolidate into a shared actions/github-script step matching bot-pr-trigger-reviews logic (dedupe if comments already exist).

Also: use GH_TOKEN PAT for gh pr create itself (not App token) where possible — PAT-created PRs are more likely to trigger downstream workflows.

2. Idempotent review-chain helper in auto-pr-comment.yml

Extract bot-pr-trigger-reviews body into a reusable composite action or callable workflow (workflow_call) so both:

  • pull_request: opened (existing path)
  • claude.yml post-create step
  • workflow_dispatch with pr_number input (manual recovery)

…can invoke the same logic without duplication.

3. Scheduled / recovery scanner (belt-and-braces)

Add a lightweight cron job (e.g. every 15 min) or extend existing merge-conflict scanner to find open bot PRs where:

  • Author is praisonai-triage-agent[bot] or github-actions[bot]
  • Opened > 10 min ago
  • No @coderabbitai review comment from MervinPraison
  • No FINAL @claude comment from MervinPraison

→ Post review-chain kick via PAT.

4. Optional: claude-fallback-timeout improvement

Current claude-fallback-timeout waits 15 min on pull_request: opened — useless if opened never fired. Change trigger to also run from recovery scanner or repository_dispatch.


Acceptance criteria

  • Bot-created PR gets @coderabbitai review + /review within 2 min even when pull_request: opened does not fire
  • Burst creation of 3+ bot PRs in <30s — all get review chain kick
  • No duplicate @coderabbitai / @claude comments (dedupe guard)
  • Manual recovery: gh workflow run bot-pr-recovery.yml -f pr_number=XXXX
  • Document in .agent/workflows/review-chain.md

Test plan

  1. Simulate bot PR create from claude.yml on a test issue; verify review comments appear without relying on pull_request: opened.
  2. Open 3 bot PRs in rapid succession; confirm all receive chain kick.
  3. Re-run scenario from fix: add runtime control surface commands to gateway bots #2245: PR with only Greptile comment → recovery scanner posts chain within 15 min.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    claudeAuto-trigger Claude analysis

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions