ci: nudge CodeRabbit awake when it rate-limits on our own PRs - #212
Conversation
CodeRabbit posts a "Review limit reached" comment and only retries on its own cooldown or an explicit "@coderabbitai review" mention. If nobody pushes a new commit to a stalled PR meanwhile, that comment just sits there. Add a scheduled workflow (every ~15 min, offset from the hour boundary) that checks our own open PRs (opened by the repo owner, or carrying a "Co-Authored-By: Claude" commit trailer): if the last CodeRabbit comment is a rate-limit notice and we haven't already nudged since, post "@coderabbitai review" to wake it up. Replaces the equivalent Claude Code Remote Routine with an in-repo CI job so it doesn't depend on any particular session being alive. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D6Naf8CcezjCbikueKdeYv
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a scheduled and manually triggered GitHub Actions workflow that scans eligible open pull requests, detects CodeRabbit rate-limit notices, and posts a deduplicated ChangesCodeRabbit nudge automation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant GitHubActions
participant GitHubAPI
participant PullRequest
GitHubActions->>GitHubAPI: Fetch open pull requests
GitHubAPI-->>GitHubActions: Return pull requests
GitHubActions->>GitHubAPI: Fetch commits and comments
GitHubAPI-->>GitHubActions: Return eligibility and comment history
GitHubActions->>PullRequest: Post review prompt when required
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 213f2e8c72
ℹ️ 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".
| const { data: comments } = await github.rest.issues.listComments({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: pr.number, | ||
| per_page: 100, | ||
| }); |
There was a problem hiding this comment.
Page through comments before nudging
When a PR has more than 100 issue comments, this only inspects the first page of GitHub's ascending issue-comment list, so later CodeRabbit comments and later github-actions[bot] nudges are invisible. In that scenario, a rate-limit notice among the first 100 comments can cause this scheduled workflow to post @coderabbitai review again every 15 minutes even after it already nudged, or it can ignore a newer non-rate-limit CodeRabbit comment; use pagination or request the newest page before deciding.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.github/workflows/coderabbit-nudge.yml (2)
77-79: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low valueGuard against a missing comment body.
lastRabbit.bodyis assumed to be a string; if it's evernull/undefined,.toLowerCase()throws and aborts the whole run mid-loop. A nullish guard keeps the loop resilient.🛡️ Optional guard
- const isRateLimited = lastRabbit.body - .toLowerCase() - .includes(RATE_LIMIT_MARK); + const isRateLimited = (lastRabbit.body ?? "") + .toLowerCase() + .includes(RATE_LIMIT_MARK);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/coderabbit-nudge.yml around lines 77 - 79, Guard the `lastRabbit.body` access in the `isRateLimited` check so null or undefined bodies do not call `toLowerCase()`; use a null-safe fallback while preserving the existing `RATE_LIMIT_MARK` detection.
40-45: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueOpen PRs beyond the first 100 are silently skipped.
pulls.listfetches only the first page. If the repo ever has more than 100 open PRs, some eligible stalled PRs won't be nudged. Given the narrow scope this is low-risk, butgithub.paginatemakes it robust.♻️ Optional: paginate the PR list
- const { data: prs } = await github.rest.pulls.list({ - owner: context.repo.owner, - repo: context.repo.repo, - state: "open", - per_page: 100, - }); + const prs = await github.paginate(github.rest.pulls.list, { + owner: context.repo.owner, + repo: context.repo.repo, + state: "open", + per_page: 100, + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/coderabbit-nudge.yml around lines 40 - 45, Update the PR retrieval in the workflow’s script to use Octokit’s github.paginate with pulls.list instead of a single paginated request, preserving the existing owner, repo, state, and per_page options so all open PRs are evaluated by the nudge logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/coderabbit-nudge.yml:
- Around line 64-95: Paginate PR comments before applying the latest-comment
checks: replace the single issues.listComments call with github.paginate using
the same repository and issue parameters, then retain the existing CodeRabbit
rate-limit and github-actions nudge logic over the complete result. Also update
the listCommits call used by the Co-Authored-By: Claude check to use
github.paginate so commit detection is not truncated after 100 entries.
---
Nitpick comments:
In @.github/workflows/coderabbit-nudge.yml:
- Around line 77-79: Guard the `lastRabbit.body` access in the `isRateLimited`
check so null or undefined bodies do not call `toLowerCase()`; use a null-safe
fallback while preserving the existing `RATE_LIMIT_MARK` detection.
- Around line 40-45: Update the PR retrieval in the workflow’s script to use
Octokit’s github.paginate with pulls.list instead of a single paginated request,
preserving the existing owner, repo, state, and per_page options so all open PRs
are evaluated by the nudge logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f739bcc3-baf7-4968-aa44-2875ab04564c
📒 Files selected for processing (1)
.github/workflows/coderabbit-nudge.yml
github.rest.*.list* calls only return the first page (max 100 items). On a PR with more than 100 comments, the unpaginated listComments call picked the "last" CodeRabbit comment from just the first page, not the actual latest one — breaking both the rate-limit detection and the already-nudged dedup check, and risking a re-nudge every run. Same truncation risk applied to the open-PR list and the per-PR commit list. Switch all three to github.paginate. Also guard lastRabbit.body with a nullish fallback so a comment body that's ever null/undefined doesn't throw and abort the loop. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D6Naf8CcezjCbikueKdeYv
CodeRabbit's own cooldown is roughly an hour, so a 15-minute loop would just burn its rate-limit window (or tip into usage-based billing) without getting reviews any sooner. One nudge per hour, offset from the :00 boundary. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsWw4Ay8KLTHFom1HvRu3U
Что и зачем
CodeRabbit при упоре в rate limit постит комментарий "Review limit reached" и сам просыпается только по своему кулдауну или по явному упоминанию
@coderabbitai review. Если в застрявший PR никто не пушит новый коммит, комментарий так и висит без движения. Новый workflow (coderabbit-nudge.yml) раз в ~15 минут проверяет наши открытые PR (автор — владелец репо, либо коммит с трейлеромCo-Authored-By: Claude) и, если последний комментарий кролика — именно rate-limit, а нового толчка с тех пор не было, оставляет@coderabbitai review.Тип изменения
Как проверено
python tests/run_tests.pyruff check .иmypypython scripts/<...>.py --selftest)Это чистый CI/YAML + встроенный
actions/github-script, питоновский код не тронут. Синтаксис workflow проверен локально (yaml.safe_load), встроенный JS-скрипт —node --check. Живьём отработает только по расписанию/workflow_dispatchв этом репозитории (нет доступа к GitHub Actions раннерам из песочницы).Связанные issue
Нет — вспомогательная автоматизация, не привязана к конкретному issue.
Чеклист
workflow_dispatchfeat:,fix:,docs:…)Generated by Claude Code
Summary by CodeRabbit