Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): keep Claude reset times on quick retries #18616

Mergedrealhasanshoaib(GitHub profile, opens in a new tab)merged 9 commits intomain fromrefs/pull/18616/headmerged by juliusmarminge View on GitHub

A quick retry after a Claude usage limit can lose its reset time, disabling existing automatic recovery. Claude suppresses unchanged rate_limit_event frames but repeats the reset in the blocked root assistant’s api_error_params.rate_limit_info.

The adapter now validates that structured payload and keeps it on the latest root response. A later root response clears it; nested responses cannot set or clear it. Event-provided resets remain authoritative for the same window, all rejected windows participate in reset selection, and missing or invalid reset timestamps hold recovery. Valid timestamps from newer window names remain supported. Overage metadata cannot supply a reset. The existing failure and server recovery paths handle ordinary turns and background wake continuations. Main is merged and contributor commits are preserved.

This focused maintainer takeover addresses #15665 without a cross-turn cache, settings, or wire changes.

Verification at 07d581db8f:

  • Adapter tests: 285 passing / 3 failing → 288 passing. Exactly two cases were added, matching the author’s final trimmed count: embedded-only wake continuation and competing rejected windows. The latter now uses a future window name, exposing a compatibility regression before its fix without adding a case. Four existing retry rows now carry embedded metadata and assert root/nested isolation and clearing after a later root response. The existing event-present wake case also checks same-window precedence.
  • 320 focused tests pass: adapter 288, Claude usage 11, and persisted server recovery scenarios 21. The primary agent independently reran this scope. Recovery scenarios exercise resume, snooze, cancellation and stale runs; they do not represent a live scheduler/client pass.
  • Real Claude Code 2.1.303, isolated home, synthetic OAuth token, loopback subscription-limit endpoint: two immediate blocked turns made two local requests. Both root assistants carried the same reset; only the first turn emitted a standalone rate-limit event. The second emitted none. Expected CLI exit 1 because both turns were limited. No real account or subscription quota used.
  • Server typecheck, targeted lint, formatting and whitespace checks passed. Lint retains one existing unused layer warning.
  • Current-head CI and bot checks pass, with skipped jobs left as configured. An existing steering test failed in the first server-shard run; local isolation and the full adapter rerun passed, followed by a successful unchanged CI rerun. No code or timeout changes were made for the rerun.
  • Two full-diff review rounds on Claude Opus 5.5 and GPT-6 Sol. Round one caught an unnecessary known-window restriction; it was reproduced in an existing test and removed. Both second-round reviews found no substantive issues. The historical stale-root P1 is guarded by the strengthened retry matrix.

This is a server adapter correction shared by web, desktop and mobile; screenshots do not apply. The original screenshots and recording predate this rebuild and are replaced by current-head nonvisual evidence. Running-client snooze/automatic recovery, a live scheduler, real accounts, relay/tunnel, macOS, Windows, iOS, Android and Electron desktop were not verified.

Credit to @realhasanshoaib for the original #18616, and @EhsanulHaqueSiam for the embedded-payload reproduction.

Tests: GPT-6 Astra; implementation: GPT-6.1 Sol; reviews: Claude Opus 5.5 and GPT-6 Sol, through T3 Code’s Codex/Claude harnesses.

    1. chatgpt-codex-connector[bot](GitHub profile, opens in a new tab)commented

      Codex Review Summary

      This comment shows the latest Codex review activity on this pull request.

      ReviewStatusCommitReview trigger
      📝 Code Review✅ Completed 2026-10-12T12:27:36.470858Zd10d0e2New commits
      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review" or "@codex security review".

      Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

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

      Approvability

      Verdict: Approved at 07d581d

      Macroscope's review found this PR approvable — This is a localized Claude adapter fix that restores reset times lost on quick retries while preserving existing limit handling and overage behavior. The companion changes are test-only and cover the new embedded-payload and precedence cases.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Note

      Reviews paused

      It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

      • Last reviewed commit: 07d581db8fedb79acc65ac67b3a7394cfb46d8ce

      Use the following commands to manage reviews:

      • @coderabbitai resume to resume automatic reviews.
      • @coderabbitai review to trigger a single review.

      Use the checkboxes below for quick actions:

      • ▶️ Resume reviews
      • 🔍 Trigger review

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: dc31bdb1-d60b-42dc-b86b-45756b95d740
      📥 Commits

      Reviewing files that changed from the base of the PR and between b6a95c2dace257ce446520c257f6fd08eb8a5553 and 07d581db8fedb79acc65ac67b3a7394cfb46d8ce.

      📒 Files selected for processing: 2
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

      📝 Walkthrough

      ClaudeAdapterV2 now tracks validated reset data from rate-limit events and rejected assistant messages. It uses assistant-reported reset data when no matching event reset exists. Tests cover reset selection and wake-rate-limit continuation.

      Changes: Claude usage-limit reset handling

      Layer / File(s)Summary
      Normalize rate-limit event reset times
      apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
      A shared helper validates and converts supported epoch-second reset values to ISO timestamps. Rate-limit event handling uses this helper.
      Capture and aggregate assistant reset metadata
      apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
      Root assistant messages can supply validated rejected-limit metadata unless overage is allowed. The adapter uses the assistant reset when no event reset exists for that limit type. Tests cover event-versus-assistant reset selection, retries, and wake-rate-limit continuation with and without a standalone event.

      Priority: ➖ Normal

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to 07d58

      The reset handling is mergeable after normal checks. Recovery remains unavailable when the rejected windows do not provide enough trustworthy timing information.

      Security architecture risk: 🔵 Low · up to 07d58

      The change retains existing recovery preferences and validates reset times. No new access or permission exposure was identified, but an unresolved retry-exhaustion edge case leaves some uncertainty about automatic recovery timing.

      Retained concerns No architecture-level concerns identified.

      Security review details

      Security Blast Radius

      • inferred — The demonstrated effect is recovery eligibility and timing for the associated failed thread and run. Continuation commands retain that thread and run identity; the inspected change does not introduce a new command destination or permission setting.

      Trust Boundaries and Controls

      • observed — Embedded resets are read only from non-replayed root assistant rate-limit errors with rejected structured metadata. Nested messages cannot populate this record, and overage-allowed metadata cannot supply its reset. Existing authentication and terminal-status checks further constrain usage-limit classification.

      Resilience and Maintainability Implications

      • observed — Existing recovery command generation excludes archived or settled threads, pending runtime requests, and resets no later than the failed run's completion. It uses deterministic thread/run/reset identities and requires armed automatic recovery to be due before generating continuation.
      • inferred — Retry-attempt freshness remains conditional on producer ordering: api_retry preserves embedded evidence, while a later root assistant replaces it. The existing exhausted-retry test ends directly in a status-529 result, which the classification guard excludes; it does not resolve the case of an intervening retry followed by a terminal error without explicit status.
      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly describes the primary fix: preserving Claude reset times during quick retries. It uses a concise conventional commit format.
      Linked Issues checkPassedThe change satisfies the coding requirements in [#15665]. ClaudeAdapterV2 validates embedded api_error_params.rate_limit_info from root assistant errors, rejects invalid and overage data, ignores …
      Out of Scope Changes checkPassedThe changes remain within [#15665]. Production changes are limited to Claude adapter reset evidence and selection. Tests cover the required recovery behavior. The reviewed scope adds no cross-turn cac…
      Description checkPassedThe description clearly explains the problem, implementation, scope, verification results, limitations, linked issues, and agent attribution. It does not use the template headings, and it does not pro…
      Full details: Linked Issues check

      Explanation

      The change satisfies the coding requirements in [#15665]. ClaudeAdapterV2 validates embedded api_error_params.rate_limit_info from root assistant errors, rejects invalid and overage data, ignores nested responses, preserves valid event timestamps for the same window, and considers other rejected windows. The selected reset reaches the existing recovery path. Tests cover embedded-only wake recovery, event precedence, clearing after a later root response, and competing windows.

      Full details: Out of Scope Changes check

      Explanation

      The changes remain within [#15665]. Production changes are limited to Claude adapter reset evidence and selection. Tests cover the required recovery behavior. The reviewed scope adds no cross-turn cache, settings change, wire change, client change, text parsing, or unrelated feature.

      Full details: Description check

      Explanation

      The description clearly explains the problem, implementation, scope, verification results, limitations, linked issues, and agent attribution. It does not use the template headings, and it does not provide an explicit maintainer approval comment or a clear explanation of why prior approval was unnecessary. These are documentation gaps, but the description is otherwise complete and directly relevant.

      ✨ Finishing Touches: 💡 1
      🛠️ Fix failing CI checks: 💡
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    5. juliusmarminge added labelsmacroscope-review

    6. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: c7ba802d2b

      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review".

      If Codex has suggestions, it will comment; otherwise it will react with 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

    7. juliusmarminge assignedjuliusmarminge

    8. Taking over this one. I will rebuild the embedded reset handling on current main, retain the minimum runtime regressions, and verify quick retry, background wake, event precedence and later-response clearing. I will preserve your commits and push the focused adapter fix here. No merge is planned.

    9. I statically reviewed the rebuilt adapter and runtime regressions. No additional actionable code issue found in that pass, but current CI is not green: Test Server 7 fails moves the root's foreground subagents to the background before a steer (answers after the steer went out) with Timed out waiting for background request. The shard reports 1 failed / 1035 passed. Build/typecheck, lint and the other server shards passed. Please isolate this failure before merging; the log alone does not establish whether it is flaky or caused by this change. I have not rerun tests.

      Failing job: https://github.com/pingdotgg/t3code/actions/runs/39252015565/job/118057870861

    10. @realhasanshoaib Thanks for checking the rebuilt head and flagging the CI failure. I isolated the unchanged steering group: the exact CI row passed locally; one of its neighboring rows (never answers) instead hit a timeout in that isolated run. The same six rows passed against the main adapter, and the complete adapter suite then passed 288/288 at 07d581db8f. The failing test and its steering/backgrounding path are unchanged by this patch; the CI failure occurs waiting for the background request before rate-limit handling. This points to scheduling sensitivity, but the local results alone do not prove the CI cause. I am rerunning the failed CI jobs once, with no code or timeout changes.

      I also checked CodeRabbit’s retry-exhaustion caveat: preserving the latest root limit through api_retry matches main’s existing classification behavior. A later root response replaces/clears the evidence; explicit non-429 terminal statuses keep their existing exclusion. No producer evidence was provided showing a stale reset on a terminal error without status, so I am leaving that classification policy unchanged in this focused fix.

    11. The unchanged CI rerun passed, including all eight server shards, build/typecheck, lint and the aggregate check. Current-head bot checks pass and there are no unresolved review threads. The body now records the failed first attempt and successful rerun. Ready for maintainer review; unmerged.

    12. juliusmarminge merged this9957790

    13. juliusmarminge closed this

Sign in to join this conversation.