Skip to content

fix: batch review comments to avoid secondary rate limit#206

Open
Br1an67 wants to merge 1 commit intoanc95:mainfrom
Br1an67:fix/issue-201-rate-limit-batching
Open

fix: batch review comments to avoid secondary rate limit#206
Br1an67 wants to merge 1 commit intoanc95:mainfrom
Br1an67:fix/issue-201-rate-limit-batching

Conversation

@Br1an67
Copy link

@Br1an67 Br1an67 commented Mar 1, 2026

What

Split large review submissions into smaller batches to avoid GitHub's secondary rate limit.

Closes #201

Why

When a PR has many changed files (100+), the review can contain hundreds of comments. Submitting all of them in a single createReview call triggers GitHub's secondary rate limit which limits content-generating requests to 80 per minute. This causes an infinite retry loop as described in #201.

How

  • If comments count is within REVIEW_BATCH_SIZE (default: 40), behavior is unchanged — single API call
  • If comments exceed the batch size, they are split into batches with a configurable delay between each batch (REVIEW_BATCH_DELAY_MS, default: 5000ms)
  • The first batch carries the "Code review by ChatGPT" body (used for bot review detection in synchronize events)

New environment variables (optional)

Variable Default Description
REVIEW_BATCH_SIZE 40 Maximum comments per review API call
REVIEW_BATCH_DELAY_MS 5000 Delay in milliseconds between batch submissions

Testing

  • TypeScript compilation passes (only pre-existing .cjs errors)
  • Small PRs: no behavior change (single call path)
  • Large PRs: comments split into batches with delay, avoiding secondary rate limit

When a PR has many changed files, the review can contain hundreds of
comments. Submitting them all in a single createReview call triggers
GitHub's secondary rate limit. Now splits comments into configurable
batches (default 40) with a delay between each batch (default 5s).

New env vars (optional):
- REVIEW_BATCH_SIZE: max comments per review (default: 40)
- REVIEW_BATCH_DELAY_MS: delay between batches in ms (default: 5000)

Small PRs (<=40 comments) are unaffected — same single-call behavior.
@Br1an67 Br1an67 mentioned this pull request Mar 1, 2026
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.

Rate limit

1 participant