Repository navigation
fix(pr-review): robust rate-limit detection and fallback across all tiers - #225
Conversation
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ 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: a28aec746f
ℹ️ 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".
|
|
||
| case "$DEV_LEAD_ENGINE" in | ||
| claude) | ||
| npm install -g @google/gemini-cli || true |
There was a problem hiding this comment.
Recompute the model before enabling Gemini fallback
When DEV_LEAD_ENGINE=claude and Claude exits with the rate-limit code, the newly installed Gemini CLI makes the fallback path reachable, but scripts/engine.sh computes run_writer_with_fallback's model once from the initial Claude ENGINE_ACTION_MODEL before looping over fallback engines. That means this line enables a call to gemini --model claude-sonnet-4-6, which is a Claude model identifier, so Gemini fails as a normal engine error instead of providing a fallback. Recompute the model per fallback engine or pass a Gemini model before installing/using Gemini as a Claude fallback.
Useful? React with 👍 / 👎.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 57c83c67ca
ℹ️ 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".
| export OUTPUT_FILE | ||
| run_agentic prompts/cascade-action.md "$ENGINE_ACTION_MODEL" > "$VERDICT_JSON.raw" | ||
| extract_verdict_json "$VERDICT_JSON.raw" "$VERDICT_JSON" || { echo "::error::cascade-action did not produce valid JSON"; exit 1; } | ||
| run_agentic prompts/cascade-action.md "$ENGINE_ACTION_MODEL" > "$VERDICT_JSON.raw" 2>/tmp/cascade/action.log || true |
There was a problem hiding this comment.
Clear stale verdicts before ignoring action failures
When review-batch.sh reviews multiple PRs in one job, /tmp/cascade is reused and this path does not remove the previous /tmp/cascade/cascade-action-verdict.json before running the action step. Because the new || true suppresses a non-zero engine exit, extract_verdict_json can immediately accept the old $VERDICT_JSON file and skip the rate-limit/error checks, causing a failed or rate-limited action on the current PR to post a stale verdict from an earlier PR instead of falling back.
Useful? React with 👍 / 👎.
| run_agentic prompts/security-audit.md "$ENGINE_AUDIT_MODEL" \ | ||
| > /tmp/cascade/audit.log 2>&1 | ||
| > /tmp/cascade/audit-stdout.txt 2>/tmp/cascade/audit.log || true |
There was a problem hiding this comment.
Remove stale audit output before suppressing failures
In batch runs, /tmp/cascade/audit.json can still contain the previous PR's security-audit result because this script never clears /tmp/cascade between PRs. With the new || true, a current audit invocation that exits non-zero before writing its own JSON is no longer stopped by set -e; the following validation can accept the old audit file and proceed with the prior PR's audit decision instead of detecting the current rate limit or failure.
Useful? React with 👍 / 👎.
| run_agentic prompts/cascade-action.md "$ENGINE_ACTION_MODEL" > "$VERDICT_JSON.raw" | ||
| extract_verdict_json "$VERDICT_JSON.raw" "$VERDICT_JSON" || { echo "::error::cascade-action (audit) did not produce valid JSON"; exit 1; } | ||
|
|
||
| run_agentic prompts/cascade-action.md "$ENGINE_ACTION_MODEL" > "$VERDICT_JSON.raw" 2>/tmp/cascade/action-audit.log || true |
There was a problem hiding this comment.
Clear stale audit verdicts before ignoring action failures
For PRs that reach the security-audit path, /tmp/cascade/cascade-action-verdict-audit.json is also reused across PRs and is not removed before this action invocation. If the current action step exits non-zero before producing a verdict, the added || true lets extract_verdict_json accept the old audit-action verdict and post that stale review for the current PR, bypassing the intended rate-limit/error handling.
Useful? React with 👍 / 👎.



This PR fixes failures in the PR review agent when Claude is rate-limited. It adds robust rate-limit and CLI error detection across all cascading tiers (Triage, Deep Review, Synthesis, Security Audit, and Action) by inspecting both stdout and stderr. This ensures that rate limits correctly trigger the fallback mechanism to Gemini or Copilot even if they occur after the initial triage tier.