Skip to content

ci: nudge CodeRabbit awake when it rate-limits on our own PRs - #212

Merged
PhysShell merged 3 commits into
mainfrom
claude/coderabbit-nudge-workflow
Jul 10, 2026
Merged

PhysShell merged 3 commits into
mainfrom
claude/coderabbit-nudge-workflow

Conversation

@PhysShell

@PhysShell PhysShell commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Что и зачем

CodeRabbit при упоре в rate limit постит комментарий "Review limit reached" и сам просыпается только по своему кулдауну или по явному упоминанию @coderabbitai review. Если в застрявший PR никто не пушит новый коммит, комментарий так и висит без движения. Новый workflow (coderabbit-nudge.yml) раз в ~15 минут проверяет наши открытые PR (автор — владелец репо, либо коммит с трейлером Co-Authored-By: Claude) и, если последний комментарий кролика — именно rate-limit, а нового толчка с тех пор не было, оставляет @coderabbitai review.

Тип изменения

  • feat — новая возможность
  • fix — исправление бага
  • docs — документация
  • refactor / chore / test / ci — без изменения поведения

Как проверено

  • python tests/run_tests.py
  • ruff check . и mypy
  • селфтесты затронутых скриптов (python scripts/<...>.py --selftest)

Это чистый CI/YAML + встроенный actions/github-script, питоновский код не тронут. Синтаксис workflow проверен локально (yaml.safe_load), встроенный JS-скрипт — node --check. Живьём отработает только по расписанию/workflow_dispatch в этом репозитории (нет доступа к GitHub Actions раннерам из песочницы).

Связанные issue

Нет — вспомогательная автоматизация, не привязана к конкретному issue.

Чеклист

  • изменение покрыто тестом/селфтестом (или объяснено, почему нет) — синтаксическая проверка YAML/JS локально, эффект наблюдаем по логам после первого scheduled run или ручного workflow_dispatch
  • README/docs обновлены при необходимости — вспомогательный CI-джоб, отдельной документации не требует
  • коммиты в conventional-commit стиле (feat:, fix:, docs: …)

Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • Added an automated workflow that periodically checks eligible open pull requests.
    • Automatically prompts CodeRabbit to retry reviews when a review rate limit is detected.
    • Supports both scheduled execution and manual triggering.

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
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fd8cf1a3-8a5c-4d48-b993-ada2e1259387

📥 Commits

Reviewing files that changed from the base of the PR and between af93d2c and 3c3b192.

📒 Files selected for processing (1)
  • .github/workflows/coderabbit-nudge.yml

📝 Walkthrough

Walkthrough

Adds a scheduled and manually triggered GitHub Actions workflow that scans eligible open pull requests, detects CodeRabbit rate-limit notices, and posts a deduplicated @coderabbitai review comment.

Changes

CodeRabbit nudge automation

Layer / File(s) Summary
Workflow triggers and execution
.github/workflows/coderabbit-nudge.yml
Configures cron and manual triggers, repository permissions, an Ubuntu job, and the GitHub Script API entry point.
PR selection and deduplicated nudge
.github/workflows/coderabbit-nudge.yml
Filters owner-opened or Claude-coauthored pull requests, checks the latest CodeRabbit rate-limit comment, and posts a new review prompt only when no newer nudge exists.

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
Loading
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly matches the main change: adding a CI workflow to nudge CodeRabbit on rate-limited PRs.
Description check ✅ Passed The description follows the template well, with all required sections present and enough detail on purpose, type, testing, and issues.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/coderabbit-nudge-workflow

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.

@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: 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".

Comment thread .github/workflows/coderabbit-nudge.yml Outdated
Comment on lines +64 to +69
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
per_page: 100,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@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 (2)
.github/workflows/coderabbit-nudge.yml (2)

77-79: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Guard against a missing comment body.

lastRabbit.body is assumed to be a string; if it's ever null/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 value

Open PRs beyond the first 100 are silently skipped.

pulls.list fetches 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, but github.paginate makes 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6d7d875 and 213f2e8.

📒 Files selected for processing (1)
  • .github/workflows/coderabbit-nudge.yml

Comment thread .github/workflows/coderabbit-nudge.yml Outdated
claude added 2 commits July 10, 2026 15:28
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
@PhysShell
PhysShell merged commit a5d611c into main Jul 10, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants