Skip to content

[Bug]: Claude usage limits show cached data as freshly checked when /api/oauth/usage is rate-limited #38070

Open

Description

@mildlyuseful

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Related: #27772 (CLI probes 429 the endpoint; asks T3 to keep the last good reading). This report is about what happens now that the last good reading is kept: it gets shown as freshly checked, and a second, uncached poller keeps the endpoint rate-limited.

Area

apps/server

Steps to reproduce

  1. Use the native Claude provider with a Claude subscription login (no CLIProxyAPI hub), on Windows or Linux.
  2. Get /api/oauth/usage rate-limited for that login. Either:
    • set Background activity → provider health refresh interval to 30 s and leave T3 Code running, or
    • click refresh on the provider or the usage limits several times in a row.
  3. Keep using Claude so real usage changes, and watch the usage limits panel.
  4. Compare usageLimits.checkedAt in ~/.t3/caches/<instanceId>.json with cachedUsageUtilization.fetchedAtMs in that login's .claude.json.

Expected behavior

While the endpoint is rate-limited, T3 keeps showing the last good reading, but with its real age, so it shows as stale once it's old. checkedAt should be when the numbers were fetched, not when T3 last asked for them.

Actual behavior

The numbers stop changing, but checkedAt moves forward on every probe, so the reading never shows as stale. After a manual refresh, an hour-old reading looks freshly confirmed.

Why it's stamped fresh

  1. probeClaudeCapabilities (src/provider/ClaudeProvider.ts) sets usageCheckedAt = now just before calling q.usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET(), and checkClaudeProviderStatus uses it as usageLimits.checkedAt.
  2. In Claude Code 2.1.326, get_usage doesn't fail when /api/oauth/usage returns 429. The probe process has sent no API request, so it has no rate-limit headers. It falls back to the snapshot it saved in .claude.json (cachedUsageUtilization, which it labels source: "persisted") and returns that as ordinary rate_limits with rate_limits_available: true. The SDK response doesn't say the data is cached or how old it is. If the saved snapshot is recent enough, Claude Code also answers from it without asking the endpoint at all ("Usage read answered from a snapshot Ns old; endpoint not asked").
  3. Because usage is present, ClaudeDriver.ts caches the result as a fresh probe for 5 minutes (CAPABILITIES_PROBE_TTL). The next probe gets the same snapshot and stamps it with a new now.
  4. Anything that judges freshness by checkedAt treats the result as current. For example, the client prefers the reading with the newest checkedAt.

Why the endpoint stays rate-limited

On every provider status check, checkClaudeProviderStatus also calls readClaudeResetCredits (src/provider/claudeResetCredits.ts). That's a direct GET /api/oauth/usage?cedar_ember=1&skip_spend=1 with no cache and no back-off, and orElseSucceed swallows the 429. The 5-minute capabilities cache doesn't cover it, so it runs at the full provider health refresh interval. readAccessToken returns undefined on macOS, so this poll only happens on Windows and Linux, which may be why #27772 (macOS) didn't see it.

With a 30 s interval and two Claude logins, the server trace has 388 readClaudeResetCredits spans in 105 minutes, about one call every 30 s per login.

Manual refreshes make it worse. Provider refresh, refreshUsage, model-cache invalidation and fresh workspace scans all call invalidateCaches first. So each click starts a new CLI usage probe and makes another direct reset-credits call. A turn that fails with usage_limit also triggers refreshUsage.

What I observed (10:15 UTC)

Login T3 usageLimits.checkedAt Claude Code cachedUsageUtilization.fetchedAtMs 5h / 7d used
A (default ~/.claude) 10:09:49Z 09:44:34Z 2% / 36% (identical)
B (custom homePath) 10:07:44Z 09:12:16Z (63 min old) 0% / 7% (identical)

Calling GET /api/oauth/usage directly at the same time: login A got 429 twice (retry-after: 0). Login B got one 200, then 429.

Impact

Major degradation or frequent failure

Usage limits look current when they can be an hour old, with nothing on screen to say so. That makes them unreliable for deciding when to switch accounts or start a long task.

Version or commit

T3 Code Nightly 0.1.11-nightly.20261117.4814

Environment

Windows 11, desktop app, Claude Code 2.1.326 (native install), two Claude subscription logins, no hub.

Logs or stack traces

# ~/.t3/caches/claudeAgent.json
"usageLimits": { "checkedAt": "2026-11-17T10:09:49.142Z", "windows": [
  { "id": "five_hour", "usedPercent": 2,  "resetsAt": "2026-11-17T13:30:00.488Z" },
  { "id": "seven_day", "usedPercent": 36, "resetsAt": "2026-11-20T21:00:00.488Z" } ] }

# ~/.claude.json (same login)
"cachedUsageUtilization": { "fetchedAtMs": 1794908674467,   # 2026-11-17T09:44:34Z
  "utilization": { "five_hour": { "utilization": 2, ... }, "seven_day": { "utilization": 36, ... } } }

# GET https://api.anthropic.com/api/oauth/usage  (10:12:57Z)
HTTP 429  retry-after: 0
{"error":{"type":"rate_limit_error","message":"Rate limited. Please try again later."}}

# server.trace.ndjson, 08:29Z-10:14Z
readClaudeResetCredits     388 spans  (~3.7/min across 2 logins, median 55 ms, every exit "Success")
checkClaudeProviderStatus  589 spans

Suggested fix

  1. Use a real fetch time. Don't stamp CLI get_usage results with the probe time. Either use cachedUsageUtilization.fetchedAtMs from the login's .claude.json when its values match the response, or take the usage windows from T3's own direct /api/oauth/usage read, which has a real response time.
  2. One read, not two. readClaudeResetCredits already fetches /api/oauth/usage. A single request could provide both the usage windows and the reset credits, instead of two separate pollers hitting the same per-account limit.
  3. Cache that read and back off. Cache the read and back off on 429. Honour Retry-After, with a minimum, since the endpoint sends 0. Use one throttle for every refresh route: the interval, manual refresh, refreshUsage, workspace scans and model refreshes. This is ask 3 in [Bug]: Native Claude provider: usage probes hit /api/oauth/usage with no back-off and drop the last good reading (429s) #27772.
  4. Keep the old timestamp. While rate-limited, keep the last good reading with its original checkedAt, so the existing stale and age display works.

Workaround

Set the provider health refresh interval to 5 minutes or more, and avoid repeated manual refreshes. To see how old the numbers really are, check cachedUsageUtilization.fetchedAtMs in the login's .claude.json.


Investigated and drafted with Claude Code from the installed Nightly build.

Activity

  1. VDrozd-Cyclis commented on Nov 18, 2026

    @VDrozd-Cyclis

    I reproduced the missing reset credits on T3 Code 0.1.10, using the macOS desktop client connected to a Linux x64 server with Claude Code 2.1.326. The provider health interval was 60 seconds.

    Claude Settings → Usage showed two reset credits, one Weekly and one Fable. T3 Usage → Limits showed the matching usage bars (43% weekly remaining and 80% Fable remaining) with no reset badge.

    On November 18, the Linux server trace recorded eight consecutive HTTP 429 responses from the reset-credit lookup between 08:29 and 08:35 CET. The provider snapshot at 08:33 CET contained both usage windows and omitted resetCredits. This confirms that the separate reset-credit request can be rate-limited on Linux while the usage bars still render.

  2. edwardEsmerson commented on Nov 20, 2026

    @edwardEsmerson

    Reproduced the intermittent missing Claude reset credits on T3 Code Desktop 0.1.11-nightly.20261119.4928 (local server, Linux x64, Claude Code 2.1.323) with two native claudeAgent Pro accounts using separate config directories.

    Evidence

    Over ~1 hour of server.trace.ndjson, T3 made 35 calls to GET https://api.anthropic.com/api/oauth/usage?cedar_ember=1&skip_spend=1:

    • 34 × HTTP 429
    • 1 × HTTP 200

    Example sequence across three refreshes (with capabilitiesProbeCache already warm on the 2nd and 3rd):

    • T+0s: refresh → both instances returned 429 on readClaudeResetCredits (exit: Success via Effect.orElseSucceed(() => undefined)).
    • T+4s: cache-hit refresh → readClaudeResetCredits still fired uncached for both instances; one got 200 (reset credits appeared) and one got 429.
    • T+41s: cache-hit refresh → both got 429, which overwrote the snapshot without resetCredits and hid the reset credits again while the usage bars stayed populated.

    (Note: another local tool on this machine also periodically calls CLI get_usage, which increases /api/oauth/usage rate-limit pressure, making T3's uncached readClaudeResetCredits calls and lack of 429 carry-over hit almost continuously.)

    Relevant code on e8c4824b

    • apps/server/src/provider/Drivers/ClaudeDriver.ts: readClaudeResetCredits runs outside capabilitiesProbeCache with no cache or Retry-After backoff, firing both immediately after probeClaudeCapabilities (get_usage) and on every cache-hit refresh.
    • apps/server/src/provider/claudeResetCredits.ts & packages/provider-core/src/server/usageLimits.ts: Effect.orElseSucceed(() => undefined) collapses 429 into "no credits", and resolveUsageLimitsAfterProbe replaces the previous snapshot whenever probed.unavailable is unset, dropping previously known resetCredits.

    Same underlying issue as #34296, #37053, and open PR #33979.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions