Usage-limit auto-resume waits for original resetAt even after quota replenishes early #46718
What happened#
Threads waiting for a usage-limit reset with auto-resume armed stay paused until the original failure resetAt timestamp even when quota replenishes earlier (for example after redeeming a reset credit, adding/re-enabling an account in a CLIProxy hub, or an out-of-band/plan reset).
Diagnosis#
Confirmed on upstream/main (4ddd02d137). Three layers lock an armed thread to the initial failure resetAt:
- UsageLimitRecoveryWorker.limitRecoveryCommand returns null while resetMs > nowMs, and makeSweep only invalidates its DueHint on orchestrator.streamDomainEvents and settings.streamChanges (not UsageLimitSources or ProviderInstanceRegistry usage updates).
- ProjectionStore.getLimitRecoveryCandidates and getLimitRecoveryWakeAt filter strictly by failure.resetAt <= now.
- Orchestrator rejects/drops usageLimitContinuationOfRunId if recovery.resetAt !== failure.resetAt or Date.parse(recovery.resetAt) > now.
Additionally, usage-limit polling in UsageLimitSources and managedProvider is gated on shouldRunScopeWork({ type: "provider-status" }), which in BackgroundPolicy (outside performance profile) requires an active foreground client lease. When T3 Code is unfocused/minimized, polling stops so early replenishment would not be detected unless armed threads are accounted for.
Steps to reproduce#
- Hit a usage limit on a thread and arm auto-resume (waiting for resetAt).
- Replenish quota before resetAt (e.g. call provider.consumeResetCredit, add/re-enable an account in a configured CLIProxy/HTTP usage hub, or reset quota on the provider).
- Observe the thread remains waiting until the original resetAt instead of resuming.
Version#
0.1.14-nightly.20261201.5530 (also on upstream/main 4ddd02d137)
Environment#
Fedora Linux 44, Node v24.22.2
Evidence#
apps/server/src/orchestration-v2/UsageLimitRecoveryWorker.ts: limitRecoveryCommand checks resetMs > nowMs; makeSweep ignores UsageLimitSources/ProviderInstanceRegistry
apps/server/src/orchestration-v2/ProjectionStore.ts: getLimitRecoveryCandidates / getLimitRecoveryWakeAt filter by resetAt <= now
apps/server/src/orchestration-v2/Orchestrator.ts: drops usageLimitContinuationOfRunId when resetAt !== failure.resetAt or > now
apps/server/src/usage/UsageLimitSources.ts & packages/provider-core/src/server/managedProvider.ts: poll gated on provider-status BackgroundScope
Related issues#
Checked #26574 (closed), #32015, #33708, #45645, #45646 — none cover waking armed threads on early quota replenishment.
Fix applied or workaround#
Manually resume/retry the thread after quota replenishes.
Filed by#
antigravity (Gemini 4 Hydrogen) via t3 triage
vibhor1102(GitHub profile, opens in a new tab) added labelsvia-triage
tanstack-source added labelsbug
juliusmarminge closed this
Sign in to join this conversation.
This is the same problem as #22307, so I'm closing it in favour of that one. If it is different, say how and it will be reopened.