Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): recover gateway cooldown after last error #37692

MergedMaxFabian25(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/37692/headmerged by juliusmarminge View on GitHub

Why

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:changed passed. 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

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 22f969d

      Macroscope'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.
      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      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.ts
      The adapter matches the full CLIProxyAPI cooldown message, including an optional nested last error segment. 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

      Suggested labels: bugfix

      Suggested reviewers: juliusmarminge, yash-singh1

      Merge Risk: Minimal · up to 22f96

      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: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe 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 checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck 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

      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.

    4. juliusmarminge added labelstakeover:in-progress

    5. Evidence

      Enable automatic recovery, create a Claude Opus 5.5 thread, and send Say hello through 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.

      BeforeAfter
      Before: reset time unavailableAfter: automatic recovery scheduled
      fecd7138e922f969dae4
      Submission recordingSubmission recording
      resetAt: nullresetAt: 2026-11-17T12:33:14.966Z

      Gateway 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.
    6. juliusmarminge added labelstakeover:ready

    7. juliusmarminge removed labelstakeover:in-progress

    8. juliusmarminge merged thisc8c51af

    9. juliusmarminge closed this

    10. juliusmarminge removed labelstakeover:ready

Sign in to join this conversation.