code review agent hit GraphQL rate limit mid-review while posting batch comments
Fixes a review agent exhausting the GitHub GraphQL rate limit while posting review comments. Use it when batch comment mutations fail with GraphQL rate limit errors mid-review. Key trigger: GraphQL errors about rate limits or cost while the agent posts comments in a loop.
TL;DR
Post one review, not fifty comments. GitHub lets a single pull request review mutation carry many inline comments at once, which costs a fraction of separate calls. Batch everything into one review submission per pass, check the query cost before running, and stay inside the 5,000 points per hour budget.
Verbatim error
code review agent hit GraphQL rate limit mid-review while posting batch commentsSteps
- Confirm the GraphQL budget state. Include the
rateLimit { limit cost remaining resetAt }field in a query, or read the error's cost info. GraphQL uses a points system (5,000 points per hour), not a call count.
Expected: you see how many points remain and when they reset.
- Restructure posting to one review per pass. Collect all inline comments in memory, then submit them in a single
addPullRequestReviewmutation with the fullthreadslist, instead of one mutation per comment.
Expected: posting 30 comments costs roughly one mutation's points instead of 30.
- Estimate cost before big mutations. A mutation's cost scales with the nodes it touches; keep each review submission under a few hundred comments and split into two reviews if needed.
Expected: no single mutation eats a large share of the hourly budget.
- If the budget is still exhausted, pause until
resetAt, then resume with the batched pattern. Do not fall back to per-comment REST calls; those have their own limits and will not save you.
Expected: the review completes in one batched submission after the reset.
Use this when
- A review agent hits GraphQL rate limits posting comments.
- You need to batch PR review comments into fewer mutations.
- An agent posts comments one at a time and the budget dies.
Not for this skill when
- The failure is on REST endpoints (different limit system, different fix).
- Comments fail with permission errors rather than rate limits (check the token scopes).
- The agent only reads data via GraphQL and never mutates (then the fix is query cost reduction, not batching).
Variant phrasings
- GitHub GraphQL rate limit posting review comments
- addPullRequestReview rate limit exceeded
- batch pull request review comments single mutation
Why it happens
GraphQL charges points per node touched, and a mutation per comment multiplies the cost: each one pays the mutation base cost plus per-comment node costs. Thirty individual comment mutations can burn a serious chunk of the 5,000-point hourly budget. One review mutation carrying all thirty comments pays the base cost once, which is the entire difference.
Edge cases
- A single review mutation has practical size limits. Past a few hundred inline comments, split into two or three review submissions rather than one giant one.
- Draft vs submitted: use pending review state to accumulate, then submit once. Submitting early and appending more comments costs extra mutations.
- The
rateLimitfield itself costs 1 point. Checking it once per batch is free in practice; checking it per comment is not. - If two agents post to the same PR concurrently, they share the installation's budget. Coordinate or stagger them.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_tPYvNyHkTP2KXenEQ09p0g
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.