Skip to content

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

Open
realhasanshoaib wants to merge 4 commits into
pingdotgg:mainfrom
realhasanshoaib:fix/claude-embedded-limit-reset
Open

realhasanshoaib wants to merge 4 commits into
pingdotgg:mainfrom
realhasanshoaib:fix/claude-embedded-limit-reset

Conversation

@realhasanshoaib

@realhasanshoaib realhasanshoaib commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A quick retry after a Claude usage limit can lose its reset time. The latest failure then says “Reset time unavailable; retry manually,” stops snoozing, and never auto-resumes—even though Claude sent the reset with that same failure.

The CLI throttles unchanged rate_limit_event frames. It still includes the rejected window in the root assistant's api_error_params.rate_limit_info, which T3 did not read.

Change

Read that structured payload on root assistant rate-limit errors. Keep event-provided timestamps when both sources name the same window, and keep all other rejected windows when choosing the final reset. Invalid timestamps, overage, and nested subagent errors cannot supply a root reset. Embedded metadata belongs only to the latest root response, so an internal retry cannot carry a stale limit into a later provider error. No cross-turn cache, text parsing, settings, or client changes.

Completeness: 5/5 for this fix. Web, desktop, and mobile consume the same persisted failure and server recovery path.

Scope and approval

Fixes #15665. Live trace and reproduction. This is a focused adapter bug fix that restores existing recovery behavior; it does not change defaults or add a feature. It uses the embedded-payload direction from @EhsanulHaqueSiam's reproduction on that issue. #15697 addresses the report with a broader cross-turn cache; this PR handles the observed follow-up path without that state.

Verification

  • The original reproduction failed on unchanged main, including an embedded-only background wake. After trimming the PR-added cases, all 237 Claude adapter/driver-usage tests pass.
  • 19 server recovery scenarios pass: resume, cancellation, rearming, snoozing, queued work, and stale/replaced runs.
  • Server typecheck and targeted lint pass on the M4 Mac mini. Independent Codex review completed. GitHub review identified stale embedded evidence after an internal retry; the original expanded regression failed before the follow-up fix and passed afterward. That duplicate scenario expansion is removed by the test cleanup below.
  • Real Claude Code 2.1.295, web client, isolated state, and a local mock subscription limit. On main, retrying after 16 seconds drops the reset and sends no automatic continuation after reset. With this fix, the second failure has no standalone rate-limit event but keeps its reset, snoozes, and leaves auto-resume armed. The mock responds successfully after reset; recovery dispatches Continue where you left off. and completes. No real credentials or subscription quota used.

Before is left; after is right. Synthetic project and messages only.

Image
auto-resume.mp4

The 32-second recording shows a rapid follow-up failure, snoozing, and automatic recovery through the real browser (captured at 1 fps).

Test cleanup

Removed 18 of 20 added cases (90%), including timestamp/schema examples, repeated embedded/event combinations and extra retry-matrix scenarios. Restored the pre-existing retry matrix rather than rewriting it. Two added runtime cases remain: embedded-only wake continuation and choosing the later rejected window. They catch deliberate mutations that drop the embedded reset or select the earlier window. Typechecking and schemas cover structure; they do not replace those runtime checks. No production code, dependencies or runner configuration changed.

Focused tests, server typecheck, lint and formatting pass on the M4 mini. A separate Codex review of the test-only deletion slice found no actionable regression.

GPT-6.1 Sol, high reasoning, Codex harness in T3 Code.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T12:27:36.470858Z d10d0e2 New 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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Oct 12, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at d10d0e2

Macroscope's review found this PR approvable — This is a focused Claude adapter bug fix that preserves existing rate-limit reset metadata across quick retries and adds targeted regression coverage. Runtime changes are isolated to failure bookkeeping and recovery timing, with no schema, default, security, billing, infrastructure, or static-analysis configuration impact.

Notes:

  • No code objects were reviewed. Approvability was decided on eligibility alone.

You can add or adjust custom eligibility rules. Learn more.

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Oct 12, 2026
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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: cbb6a04f-5835-49b5-99d1-97567cbf8e41

📥 Commits

Reviewing files that changed from the base of the PR and between 310ec1d and d10d0e2.


📒 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; 9 remain after this review.



📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

ClaudeAdapterV2 now reads validated reset data from rate-limit events and rejected root assistant messages. It combines eligible reset data when calculating provider failures. 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 converts valid 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 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 b6a95

The reset-handling change is mergeable after normal checks.

Architecture Summary

Architecture risk: 🔵 Low · up to d10d0

The change affects 1 system.

Changed systems: apps/server

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — apps/server (service) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts: Adds validation for the undeclared assistant api_error_params.rate_limit_info payload and a helper that converts epoch-second reset times to ISO strings only when the converted value is finite, positive, and below 8.64e15; invalid or missing times become null.
  • observed — Modified behavior in apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts: Adds latestAssistantRateLimit to the active turn context, storing a rate-limit type and nullable reset timestamp separately from the existing assistant rate-limit flag.
  • observed — Modified behavior in apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts: Replaces inline reset-time conversion with claudeUsageLimitResetAt when recording a rejected rate-limit event; the validation bounds and null fallback remain the same.
  • observed — Modified behavior in apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts: For each root assistant message, clears the prior assistant limit metadata, then records its limit type (or "unknown") and validated reset time when the message is rate-limited and its payload passes schema validation. It does not record the limit when overage is allowed.

Pre-merge checks | Passed 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed The change satisfies the coding requirement in [#15665]. Root assistant rate-limit errors now read rejected api_error_params.rate_limit_info. The adapter validates reset timestamps, ignores overage …
Out of Scope Changes check Passed The changes stay within [#15665]. Production changes are limited to Claude rate-limit evidence collection and reset selection. Test changes cover the new embedded-payload and wake behavior. The review…
Title check Passed The title clearly and concisely describes the main server fix: preserving Claude reset times during quick retries.
Description check Passed The description includes complete Problem, Change, Scope and approval, and Verification sections. It explains the bug, implementation, scope, linked issue, tests, manual validation, and observed resul…

✨ Finishing Touches
🧪 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.

@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 12, 2026 — with ChatGPT Codex Connector

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts Outdated
@macroscopeapp
macroscopeapp Bot dismissed their stale review October 12, 2026 10:46

Dismissing prior approval to re-evaluate c7ba802

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Oct 12, 2026
@macroscopeapp
macroscopeapp Bot dismissed their stale review October 12, 2026 12:18

Dismissing prior approval to re-evaluate d10d0e2

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Claude usage-limit reset shown in activity but missing auto-resume controls during subagent workflow

2 participants