Skip to content

Scale PR review sub-agents by diff size#512

Merged
strawgate merged 1 commit intomainfrom
feat/pr-review-fanout
Mar 1, 2026
Merged

Scale PR review sub-agents by diff size#512
strawgate merged 1 commit intomainfrom
feat/pr-review-fanout

Conversation

@strawgate
Copy link
Copy Markdown
Collaborator

@strawgate strawgate commented Mar 1, 2026

Summary

  • Pre-computes PR size metrics in pr-context and writes pr-size.txt as {N} files, {M} diff lines.
  • PR review prompt now uses diff line count to choose fan-out instead of always spawning 3 sub-agents:
    • Under 200 lines: review directly (no sub-agents)
    • 200-800 lines: 2 sub-agents (A→Z, Z→A)
    • Over 800 lines: 3 sub-agents (A→Z, Z→A, largest first)
  • Keeps the fan-out decision logic explicit in the PR review prompt while using precomputed pr-size.txt as input.
  • Regenerates affected compiled workflow lock files from these prompt/fragment changes.

Supersedes #510 with a simpler approach.

Test plan

  • make compile succeeds
  • All 32 tests pass
  • Verify on a small PR (<200 diff lines) that the agent reviews directly
  • Verify on a large PR (>800 diff lines) that 3 sub-agents are spawned

Generated by Update PR Body for issue #512

Pre-compute diff lines and file count in pr-context.md, write to
pr-size.txt. The PR review prompt now uses diff lines to decide:

- Under 200 lines: review directly (no sub-agents)
- 200-800 lines: spawn 2 sub-agents (A-Z, Z-A)
- Over 800 lines: spawn 3 sub-agents (A-Z, Z-A, largest first)

This keeps all logic in the prompt (readable, no indirection) and uses
diff lines instead of file count as the heuristic, which better captures
actual review complexity.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 1, 2026

Warning

Rate limit exceeded

@strawgate has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 4 minutes and 44 seconds before requesting another review.

⌛ 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.

📥 Commits

Reviewing files that changed from the base of the PR and between b3b2795 and a74a668.

📒 Files selected for processing (7)
  • .github/workflows/gh-aw-fragments/pr-context.md
  • .github/workflows/gh-aw-mention-in-pr-by-id.lock.yml
  • .github/workflows/gh-aw-mention-in-pr-no-sandbox.lock.yml
  • .github/workflows/gh-aw-mention-in-pr.lock.yml
  • .github/workflows/gh-aw-pr-review-addresser.lock.yml
  • .github/workflows/gh-aw-pr-review.lock.yml
  • .github/workflows/gh-aw-pr-review.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/pr-review-fanout

Comment @coderabbitai help to get the list of available commands and usage tips.


# Compute PR size metrics for review fan-out decisions
FILE_COUNT=$(jq 'length' /tmp/pr-context/files.json)
DIFF_LINES=$(wc -l < /tmp/pr-context/pr.diff | tr -d ' ')
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.

[MEDIUM] Diff-size fallback misclassifies PRs when full diff fetch fails

DIFF_LINES is derived only from /tmp/pr-context/pr.diff. In the failure path just above, gh pr diff can fail and the script intentionally creates an empty file (: > /tmp/pr-context/pr.diff), which forces DIFF_LINES=0 and classifies the PR as "small" even when the actual patch set is large. This defeats the fan-out logic introduced in this PR and can under-review large PRs; please fall back to counting lines from files.json patches when pr.diff is empty.

@strawgate strawgate merged commit 142ed71 into main Mar 1, 2026
18 checks passed
@strawgate strawgate deleted the feat/pr-review-fanout branch March 1, 2026 03:40
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.

1 participant