fix(github): protect pull request API budget - #6466
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
ApprovabilityVerdict: Needs human review This PR introduces a new rate limiting service that can pause GitHub API calls, changes the review thread loading strategy from eager to lazy pagination, increases the refresh interval from 1 to 5 minutes, and adds a new RPC endpoint. These are significant runtime behavior changes affecting core functionality that warrant human review. You can customize Macroscope's approvability policy. Learn more. |
Dismissing prior approval to re-evaluate d0bec12
There was a problem hiding this comment.
Two Effect service convention issues in the new GraphQL budget path. Details inline.
Posted via Macroscope — Effect Service Conventions
There was a problem hiding this comment.
Two Effect service convention issues in the new GraphQL budget path. Details inline.
Posted via Macroscope — Effect Service Conventions
Reject thread IDs from another pull request without adding a second GraphQL request.
Track quota inside the injected Effect layer and report local pauses as structured errors instead of synthetic CLI failures.
Concurrent reads can finish out of order. Keep the lower remaining quota within one reset window and ignore responses from older windows.
Problem
Opening a pull request could spend 104 GitHub GraphQL points in one read. T3 Code requested up to 100 replies for each review thread, followed every reply cursor, and refreshed activity every minute.
That can drain GitHub's shared 5,000-point hourly budget while one detail panel stays open.
Fix
updatedAtchanges.Result
A measured 44-thread pull request now costs 14 GraphQL points on its initial read instead of 104. That is an 86.5% reduction. Extra reply pages cost points only when requested.
The reserve guard also prevents T3 Code background reads from consuming the final quota needed by other GitHub clients.
Verification
Built with Codex (GPT-5.6-sol) in T3 Code.
Note
Protect GitHub GraphQL API budget and add paginated review thread comment loading
GitHubGraphQlBudgetservice that tracks GitHub GraphQL rate limit usage per host, injectsrateLimitfields into read queries, and blocks reads withGitHubGraphQlBudgetPausedErrorwhen remaining quota is at or below 10% of the limit until the reset window expires.getReviewThreadCommentsRPC (pullRequests.threadComments) for explicit cursor-based pagination of review thread comments;listReviewThreadCommentsno longer auto-fetches additional comment pages per thread.ReviewThreadCardgains a 'Load more comments' button that lazy-loads additional pages, de-duplicates comments, and resets paginated state after edits, replies, or reactions.GRAPHQL_PAGE_SIZEto 10, and validates that a requested thread belongs to the target pull request before returning results.updatedAtchanges for the same PR.listReviewThreadCommentsnow receive truncated threads with anextCommentsCursorrather than fully expanded comment lists; reads will fail with a typed error when GitHub quota is nearly exhausted.Macroscope summarized 8815403.