fix(server): recover gateway cooldown after last error #37692
main fromrefs/pull/37692/head·merged by juliusmarminge View on GitHubWhy#
Keep automatic recovery available when a gateway reports its cooldown after a parenthesised last error. A daily review hit this real 429 format, but T3 recorded no reset time, so its recovery worker could not schedule a retry.
What changed#
- Accept the last-error-first gateway format while preserving the existing reset-first format.
- Extend the adapter's direct-429 table with the captured error, differing nested resets and messages without an outer reset.
Scope#
This changes cooldown parsing and its regression tests. It changes no recovery worker, schedule, model setting or running installation.
Blast radius#
The added parser applies to the existing direct gateway 429 path. Structured SDK reset precedence and generic API error parsing remain unchanged.
Verification#
- The captured error failed before the fix with a null reset. A nested-error counterexample also failed against the first candidate and drove separate parsing of the two message orders.
vp run check:changedpassed. It ran 460 tests across the adapter and context-budget files, format, lint, both knip checks, GraphQL verification and typechecking of three affected packages.- An independent review of the revised source and tests returned PASS.
Written with Codex, GPT-6.1 Sol at xhigh effort, through T3 Code.
- 1
tanstack-source added labelsbug
Approvability#
Verdict: Approved at
22f969dMacroscope's review found this PR approvable — Restores gateway cooldown recognition when the reset follows a last-error message. Existing recovery preferences and eligibility safeguards remain unchanged, limiting the effect to the affected 429 format.
Notes:
- All code in this push has already been reviewed. Approvability was decided on eligibility alone.
No actionable comments were generated in the recent review.
Walkthrough
-
The Claude adapter now extracts reset durations from nested CLIProxyAPI 429 cooldown messages. Tests cover top-level reset values, precedence over nested values, and cases where nested rate-limit text has no directly parseable reset duration.
Changes: 429 Cooldown Parsing
Layer / File(s) Summary Parse and test nested cooldown resets
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts,apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.tsThe adapter matches the full CLIProxyAPI cooldown message, including an optional nested last errorsegment. Tests verify reset durations, outer reset precedence, and zero seconds when no direct reset duration is available.Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related PRs
- pingdotgg/t3code#25520: Adds parsing of reset-after durations for direct 429 errors in the same Claude adapter path.
- pingdotgg/t3code#26735: Extends direct 429 cooldown parsing in the Claude adapter.
- pingdotgg/t3code#25438: Adds reset-after parsing and tests for direct 429 results in the same adapter.
Suggested labels:
bugfixSuggested reviewers:
juliusmarminge,yash-singh1
Merge Risk:
Minimal · up to22f96-
This change lets gateway 429 cooldown messages that include a last error be parsed, so recovery can be scheduled. No remaining merge-blocking risk was found.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the fix (recovering gateway cooldown after a last error) and the component (server). It matches the main change: the adapter now parses 429 reset times from the last-error-first gatewa… Description check The description covers the problem, the change, scope, and verification, so it is mostly complete. It follows the template's section headings except for an added Blast radius section, which is extra b… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Title check
-
Explanation
The title names the fix (recovering gateway cooldown after a last error) and the component (server). It matches the main change: the adapter now parses 429 reset times from the last-error-first gateway format. It follows the conventional commit style the template requests.
Full details: Description check
-
Explanation
The description covers the problem, the change, scope, and verification, so it is mostly complete. It follows the template's section headings except for an added Blast radius section, which is extra but harmless. The Problem section is folded into a 'Why' section. The Verification section gives specific commands and results. It does not include an issue link or a maintainer request in Scope, and the template asks for a linked issue or a reason it needs none. The description also does not state whether the change is a bug fix for an obvious bug. These are non-critical gaps, so the check passes.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: fecd713
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
76feeecc-3326-4911-9338-5a585a952582
Commits-
Reviewing files that changed from the base of the PR and between 907988ef40e3386ff3656eb13a17142257f24676 and 22f969dae406f4162455dbe5a2a0b47bf0f52954.
Files selected for processing: 1-
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
-
juliusmarminge added labelstakeover:in-progress
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Evidence#
Enable automatic recovery, create a Claude Opus 5.5 thread, and send
Say hellothrough a stand-in gateway returning HTTP 429 with(last error: …) (reset after 19h30m2s). Both sides use fresh databases, synthetic data, Chromium at 1280×800 CSS pixels, light theme, and UTC.Before After 

fecd7138e9 22f969dae4 Submission recording Submission recording resetAt: nullresetAt: 2026-11-17T12:33:14.966ZGateway fixture · Reproduction setup · Base projection · Head projection
Not shown:
- Actual automatic execution after the 19h30m2s cooldown was not observed because it exceeds the 100-minute budget; the scheduled recovery banner and persisted reset time were verified.
- Nested upstream cooldown variants were not exercised in the real app; this proof covers the reported gateway message.
juliusmarminge added labelstakeover:ready
juliusmarminge removed labelstakeover:in-progress
juliusmarminge merged thisc8c51af
juliusmarminge closed this
juliusmarminge removed labelstakeover:ready
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes