Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Native Claude provider: usage probes hit /api/oauth/usage with no back-off and drop the last good reading (429s) #27772

Openjamesembling(GitHub profile, opens in a new tab) opened this issue 1 comment

Follow-up from #19807, split out as suggested there (thanks @JustYannicc). #19820 covers hub reads; this is the native Claude provider with one login and no CLIProxyAPI hub.

Setup: one Mac, one Claude login, T3 Code Nightly 0.1.6-nightly.20261030.3917, Claude Code 2.1.314.

What happens: every capability probe starts a fresh Claude Code process, and that process reads /api/oauth/usage. Anthropic rate-limits this endpoint per account, so the probes 429 everything else on the same login, including OpenUsage. Data is in my comment on #19807: with probes kept off the endpoint, 113 fresh reads and 0 429s; with probes allowed, a 429 within a minute.

What the code does now (per the triage on #19807, main 6fc9144a60):

  • ClaudeDriver.ts caches a probe with fresh usage for 5 minutes, but a failed read caches for zero time, so the next refresh probes again at once with no back-off.
  • refreshUsage, workspace scans and model refreshes all drop the cache before probing.
  • On failure the provider reports "unavailable" instead of the last good reading.
  • Workspace probes call it with usage off, but the CLI still seems to read the endpoint on startup unless CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 is set.

Asks:

  1. Back off after a failed usage read (honour Retry-After) and keep that across probe processes.
  2. Keep showing the last good reading while rate-limited.
  3. One throttle shared by every refresh route.
  4. Set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 for probes that don't need usage (workspace/model scans).
  5. Optionally, during active sessions, use rate_limit_event data instead of polling.

Workaround for anyone hitting this: point the Claude binaryPath at a wrapper that sets CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 for probe launches. The Limits panel then shows "unavailable", but nothing 429s.

Written by Claude Opus 5.5 (Claude Code) on behalf of @jamesembling.

  1. tanstack-source added labelsbug

  2. Still reproducible on the current stable release. Same root cause as described above, plus some details from the installed bundle.

    Environment

    • T3 Code (Beta) 0.1.13 stable, Windows 11
    • Claude Code 2.1.332 (Agent SDK 0.3.321)
    • Claude Pro subscription, one machine, one login, no linked environments

    Symptom Usage → Limits shows Codex normally. Claude has no bars, only "Could not read limits." The cached Claude provider snapshot has:

    "usageLimits": { "windows": [], "unavailable": { "reason": "probeFailed" } }

    What the endpoint returns A single direct GET https://api.anthropic.com/api/oauth/usage with the local OAuth token (anthropic-beta: oauth-2025-04-20) returns:

    HTTP 429
    retry-after: 1813
    {"error":{"type":"rate_limit_error","message":"Rate limited. Please try again later."}}

    The token is valid and has the user:profile scope. Inference keeps working normally. Only the usage endpoint is throttled.

    Why it never recovers

    1. Each capability probe (probeClaudeCapabilities) spawns a fresh Claude Code process and calls usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET(), which hits /api/oauth/usage. This runs on the 5-minute provider refresh, and refreshUsage also invalidates capabilitiesProbeCache before probing.

    2. Claude Code 2.1.332 does honour Retry-After ("429 remembered for this bearer; not asking again for Ns"), but that hold lives in process memory only. Every new probe process starts without it and asks again, so the account stays rate-limited.

    3. The CLI's persisted fallback (cachedUsageUtilization in ~/.claude.json) is only used as a seed when it is under 1 hour old. Mine was last written about 15 hours earlier, at the last successful read. So get_usage returns rate_limits_available: true, rate_limits: null, and claudeUsageResponseToLimits maps that to probeFailed.

    4. The streamed fallback doesn't help either (#30310). Active Claude sessions emit events like this one, from my own session:

      {"status":"allowed","rateLimitType":"five_hour","isUsingOverage":false,
       "unifiedWindows":{"five_hour":{"utilization":0.16,"resetsAt":1795864800,"status":"allowed"},
                         "seven_day":{"utilization":0.57,"resetsAt":1796022000,"status":"allowed"}}}

      In 0.1.13, claudeRateLimitEventToUpdate still returns early when there is no top-level utilization, so these numbers are dropped and the panel stays empty even while Claude is in use.

    Suggestions (in line with the original request)

    • Persist a per-account usage back-off that honours Retry-After across probe processes, and skip the usage call while it is active. Today nothing stops the next probe from asking again.
    • Don't invalidate the usage cache on every refreshUsage while a back-off is active.
    • Map rate_limit_info.unifiedWindows (#28869 / #31135). The bars would then fill from live sessions without polling the endpoint at all.
    • When the read fails with 429 and there is no previous reading, say it is rate-limited (and when to retry) instead of the generic "Could not read limits."

Sign in to join this conversation.