Skip to content

fix(pr-review): robust rate-limit detection and fallback across all tiers - #225

Merged
don-petry merged 6 commits into
mainfrom
fix/pr-review-rate-limit-fallback
May 17, 2026
Merged

don-petry merged 6 commits into
mainfrom
fix/pr-review-rate-limit-fallback

Conversation

@don-petry

@don-petry don-petry commented May 17, 2026 •

Copy link
Copy Markdown
Collaborator

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.

Copilot AI review requested due to automatic review settings May 17, 2026 17:26
@gemini-code-assist

Copy link
Copy Markdown

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@coderabbitai

coderabbitai Bot commented May 17, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@don-petry has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 47 minutes before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7e39757b-1f4f-43eb-b7bd-a9460034482a

📥 Commits

Reviewing files that changed from the base of the PR and between ae8d750 and 57c83c6.

📒 Files selected for processing (4)
  • .github/workflows/dev-lead-reusable.yml
  • dummy.txt
  • scripts/engine.sh
  • scripts/review-one-pr.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pr-review-rate-limit-fallback

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

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

@don-petry don-petry changed the title TEST: Dummy PR fix(pr-review): robust rate-limit detection and fallback across all tiers May 17, 2026
@sonarqubecloud

Copy link
Copy Markdown

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

Comment thread scripts/review-one-pr.sh
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

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

Comment thread scripts/review-one-pr.sh
Comment on lines 613 to +614
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

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

Comment thread scripts/review-one-pr.sh
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

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

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