fix(server): stop PR status lookups amplifying GitHub rate limits - #5673
Conversation
A failed PR lookup was cached for a flat 20s while a successful one is cached for 2 minutes, so a rate-limited poller re-asked six times faster than a healthy one. lookupStatusPr also catches the failure and returns the last known PR, so the poll succeeds and VcsStatusBroadcaster's exponential backoff never engages. A transient 429 therefore became sustained pressure. Back the failure TTL off per branch instead, and skip the provider call entirely for branches git has never seen on any remote, which cannot have a change request. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
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 |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
ApprovabilityVerdict: Approved a76cbc6 Self-contained performance optimization that adds exponential backoff for failed PR lookups and skips unnecessary API calls for branches never pushed to a remote. Well-tested with clear, conservative logic. You can customize Macroscope's approvability policy. Learn more. |
## What's Changed * feat: sidebar v2 is now the default sidebar by @t3dotgg in pingdotgg/t3code#5672 * fix(server): stop PR status lookups amplifying GitHub rate limits by @t3dotgg in pingdotgg/t3code#5673 * fix(web): delay transient reconnect warnings by @t3-code[bot] in pingdotgg/t3code#5670 * fix(web): inherit terminal size in simple typography by @chrisdeeming in pingdotgg/t3code#5628 **Full Changelog**: pingdotgg/t3code@v0.0.33-nightly.20260808.1029...v0.0.33-nightly.20260808.1030 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.33-nightly.20260808.1030
…ngdotgg#5673) Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ngdotgg#5673) Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ngdotgg#5673) Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ngdotgg#5673) Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ngdotgg#5673) Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ngdotgg#5673) Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Problem
I keep getting throttled on the GitHub API. Digging through logs, most of it is
my own agents running
ghin bursts, but T3 Code makes it worse in two ways.The PR status badge caches a successful lookup for 2 minutes and a failed
one for 20 seconds. GitHub rejects a throttled request instantly, so once you're
rate limited the poller starts asking six times faster than it does when
everything is healthy. On top of that,
lookupStatusPrcatches the failure andreturns the last known PR, so the poll reports success and
VcsStatusBroadcaster's exponential backoff never engages. Nothing ever slowsdown, and a transient 429 turns into a sustained one.
Separately, the badge asks the provider about every branch, including branches
that were never pushed anywhere. Those queries cannot match a PR. On this machine
66% of sampled t3code worktrees are in that state, so two thirds of the baseline
API spend was guaranteed-empty.
Solution
Failed lookups now back off per branch (20s, 40s, 80s, ... capped at 15 min)
instead of retrying on a flat 20s timer, so a failing branch drops below the
healthy refresh rate after a couple of attempts rather than above it.
Branches git has no record of on any remote skip the provider call entirely. The
check looks for a remote-tracking ref rather than upstream config, because
git pushwrites that ref even without-u, which is how most terminal andagent pushes land. Repositories that track no remotes at all can't answer the
question, so they keep the old behaviour, as does any failed probe: hiding a PR
badge is worse than spending the lookup.
Tests cover the backoff curve, the skip, and the case that makes the naive
version wrong (a branch pushed without
--set-upstreamstill gets looked up).Not in this PR
Two bigger wins from the same investigation, kept separate because they change
lookup semantics and deserve their own review:
gh pr listper repo matched locally by branch,instead of one call per branch. Caps the worst case (expanded thread list,
262 distinct cwds here) at a few calls instead of thousands.
during the investigation, each with independent pollers and caches against the
same token.
Made by Claude Opus 5 (1M context) in Claude Code, on T3 Code.
Note
Medium Risk
Changes PR badge lookup timing and when GitHub is contacted; incorrect unpublished detection could hide a PR badge, though failures fall back to the old lookup path.
Overview
Reduces GitHub API load from VCS PR status polling by changing how failed lookups are cached and when provider calls run.
Failed PR lookups no longer use a flat 20s cache TTL. They use per-branch exponential backoff (20s → 40s → … capped at 15 minutes), with streak tracking cleared on success, so rate-limited branches retry less often than the healthy 2-minute refresh instead of more often.
For branches without upstream config,
statuscan skipgh pr listwhen git shows remotes exist but norefs/remotes/*/<branch>for the current head—treating never-pushed local branches as having no PR. Branches that were pushed without-ustill get looked up because remote-tracking refs exist. Ambiguous cases (no remotes, or probe failure) still call the provider.Tests cover the backoff curve, the never-pushed skip, and push-without-upstream still querying GitHub.
Reviewed by Cursor Bugbot for commit a76cbc6. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix PR status lookups amplifying GitHub rate limits via exponential backoff and branch skip logic
prLookupFailureTtl(consecutiveFailures)function, resetting on success.isUnpublishedBranchcheck viagit for-each-ref.--set-upstreamstill perform the provider lookup as before.Macroscope summarized a76cbc6.