Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Claude instances authenticated with CLAUDE_CODE_OAUTH_TOKEN (claude setup-token) never appear in Usage → Limits, although their sessions stream usable rate-limit windows #24114

OpenLiri-s29(GitHub profile, opens in a new tab) opened this issue 4 comments

Before submitting

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

Area

apps/server

Steps to reproduce

  1. Create a token with claude setup-token and a wrapper script that exports CLAUDE_CODE_OAUTH_TOKEN and execs claude. Register the wrapper as a Claude provider instance (binaryPath). Repeat for a second account.
  2. Use both instances normally.
  3. Open Usage → Limits.

Expected behavior

Both accounts show session and weekly bars, or at least a notice saying why they cannot be read.

Actual behavior

Neither account is listed and there is no notice. The boot-time get_usage probe returns rate_limits_available: false for a setup-token session (confirmed by caitlon in #13053), so claudeUsageResponseToLimits marks the instance "unsupported" and collectLimitAccounts and collectLimitNotices both skip it. #18624 fixed the rate_limits_available: true + rate_limits: null shape and explicitly left this case out.

The data is available anyway. A turn on such an instance streams rate_limit_info with unifiedWindows, for example {"five_hour":{"utilization":0.2,"resetsAt":1792759800},"seven_day":{"utilization":0.59,"resetsAt":1792760400}} captured today from claude -p ... --output-format stream-json --verbose under a setup-token wrapper. T3 discards streamed windows for an instance marked unsupported.

Suggested fix: treat rate_limits_available: false as "probe unsupported, streamed windows allowed" when apiKeySource is "none" and the token is an OAuth token: show the instance in Limits as soon as a streamed rate_limit_info arrives, and keep the last streamed reading between turns. Keep "unsupported" only for API-key accounts.

Impact: Anyone running several subscriptions through setup-token wrappers (the documented way to use Claude Code on a headless or multi-account machine) has no limit visibility in T3 and cannot pick the account with headroom.

Impact

Major degradation or frequent failure

Version or commit

T3 Code Nightly 0.1.3-nightly.20261023.3553

Environment

macOS (Darwin 25.6.0, arm64), Claude Code CLI 2.1.309, three Claude subscription accounts each behind a setup-token wrapper script registered as its own provider instance.

Logs or stack traces

Stream line from a setup-token session (fields other than the rate-limit window omitted):
"rate_limit_info":{"status":"allowed","rateLimitType":"five_hour","unifiedWindows":{"five_hour":{"utilization":0.2,"resetsAt":1792759800},"seven_day":{"utilization":0.59,"resetsAt":1792760400}}}

Screenshots, recordings, or supporting files

No response

Workaround

No response

  1. Liri-s29(GitHub profile, opens in a new tab) added labelsneeds-triage

  2. Still reproduces on T3 Code Nightly 0.1.9-nightly.20261110.4465 (macOS arm64) with Claude Code 2.1.312, three setup-token accounts behind wrapper scripts.

    Why get_usage says rate_limits_available: false. When auth comes from CLAUDE_CODE_OAUTH_TOKEN, Claude Code gives the token the scopes in CLAUDE_CODE_OAUTH_SCOPES, or ["user:inference"] if that is unset. get_usage only reads plan limits when the scopes include user:profile. The default is the same in 2.1.322.

    The obvious workaround doesn't help. Setting CLAUDE_CODE_OAUTH_SCOPES="user:inference user:profile" in the wrapper flips get_usage to rate_limits_available: true, but rate_limits stays null. All three tokens get HTTP 429 from /api/oauth/usage with retry-after: 3596 (a bogus token gets 401, so they do authenticate). T3 then marks the probe probeFailed, and the streamed windows are still dropped, because the event only has unifiedWindows and no top-level utilization:

    "rate_limit_info":{"status":"allowed","rateLimitType":"seven_day","unifiedWindows":{"seven_day":{"utilization":0.03,"resetsAt":1794574800,"status":"allowed"}}}

    So a user can't work around this. It needs both parts of #24128: the setup-token probeFailed path and the unifiedWindows parsing.

  3. Same here, with some measurements that may help.

    Setup: several Claude subscriptions on one host, each instance signed in with a claude setup-token token (CLAUDE_CODE_OAUTH_TOKEN, from a wrapper binary or from --settings <file> in the instance's launch arguments).

    Why it's empty: the provider check's get_usage answers rate_limits_available: false, rate_limits: null under a setup-token, so the instance is marked unsupported until a session streams a rate_limit_event.

    T3 already has the data. Running sessions on these instances do update the bars from each rate_limit_event; it is only the check's "unsupported" result that blanks them.

    And a token gives the numbers on demand. A one-word turn under a setup-token emits a rate_limit_event with both windows in unifiedWindows:

    claude -p "Reply with exactly: ok" --model haiku --output-format stream-json --verbose \
      --no-session-persistence --strict-mcp-config
    {"type":"rate_limit_event","rate_limit_info":{"status":"allowed","rateLimitType":"five_hour",
     "unifiedWindows":{"five_hour":{"utilization":0.2,"resetsAt":...,"status":"allowed"},
                       "seven_day":{"utilization":0.35,"resetsAt":...,"status":"allowed"}}}}
    • On a subscription already at its weekly limit, the turn errors but the event still arrives (status: "rejected", both windows), so a reading costs no completed turn there.
    • An unused window can be missing from unifiedWindows (we saw only seven_day while the five-hour window was empty). Showing that as "not reported" rather than 0% would avoid a false reading.

    Two things that would fix it for token instances:

    1. Keep the last rate_limit_event limits when the provider check comes back unsupported, instead of replacing them (this looks like what #31135 does, so +1 to that).
    2. Optionally, when there is no recent event, take one reading from a minimal turn as above, behind a setting, since it spends a few tokens of the window it measures.

    Separately, on macOS the reset-credits read (readAccessToken) returns nothing because the login is in the Keychain, not .credentials.json, so that badge never shows on a Mac. Mentioning it in case it's unintended.

  4. Also hitting this, on today's T3 Code Nightly 0.1.12-nightly.20261122.5071 (macOS 27.2.1, arm64) with Claude Code 2.1.330.

    My setup is a headless Mac mini running T3 as a launchd service. CLAUDE_CODE_OAUTH_TOKEN is set in the service environment because a background service can't reliably unlock the login Keychain. So for an always-on server, a setup-token isn't an edge case: it's the only way to sign in. As a result, Claude never shows up in Usage → Limits, while Codex on the same machine does.

    Same symptoms as above:

    • The provider check's usage_EXPERIMENTAL…({ skipBehaviors: true }) returns rate_limits_available: false, rate_limits: null. tokenSource is CLAUDE_CODE_OAUTH_TOKEN and subscriptionType is empty.
    • During turns, the provider event log gets rate_limit_event with unifiedWindows.seven_day.utilization (0.44–0.45 today), but none of it reaches the Limits tab.

    What matters most here is that this is the main view I use from the iOS app to decide which provider to send work to. With Claude missing, it shows only half the picture. Keeping the last streamed windows when the check comes back unsupported (#31135), and parsing unifiedWindows (#24128), would fix it for us. +1 to getting those in.

  5. +1, still reproduces on 0.1.13 with Claude Code 2.1.332 on a headless Linux server, where the setup-token comes from CLAUDE_CODE_OAUTH_TOKEN in the service environment. I have more data on the cold-start part (no recent rate_limit_event), plus a cheaper way to take a reading than a claude -p turn.

    Why each source fails with a default setup-token (scope user:inference):

    • get_usage returns rate_limits_available: false. In the 2.1.332 bundle it is computed as "is claude.ai subscriber && has profile scope", so a setup-token never gets it, even when the CLI has cached header data.
    • GET /api/oauth/usage → 403 oauth_scope_insufficient (required_scopes: ["user:profile"]).
    • Requests that cost nothing don't help. /v1/messages/count_tokens and invalid requests (max_tokens: 0, empty messages, unknown model) come back without the unified headers.

    What works: any accepted /v1/messages request returns anthropic-ratelimit-unified-{5h,7d}-{utilization,reset} headers (0-1 fractions, epoch-second resets). The CLI's own /usage screen reads these. The cheapest request that still gets them:

    POST https://api.anthropic.com/v1/messages
    authorization: Bearer $CLAUDE_CODE_OAUTH_TOKEN
    anthropic-beta: oauth-2025-04-20
    anthropic-version: 2023-06-01
    
    {"model":"claude-haiku-5-5","max_tokens":1,
     "system":"You are Claude Code, Anthropic's official CLI for Claude.",
     "messages":[{"role":"user","content":"."}]}

    That's about 35 input tokens and 1 output token. A claude -p turn costs far more, because it sends the full CLI system prompt and tool definitions. Without the Claude Code system line, the token gets a bare 429. A claude-cli user-agent isn't required. Like the streamed event, a request that is rejected at the limit still carries the headers.

    How I wired it (on a local fork): after the capabilities probe, if tokenSource === "CLAUDE_CODE_OAUTH_TOKEN", apiProvider === "firstParty", there is no ANTHROPIC_BASE_URL, and get_usage reported rate_limits_available: false, send that request once and map the headers into the get_usage shape. The existing claudeUsageResponseToLimits and UI then show Session and Weekly unchanged. It runs inside the existing 5-minute capabilities cache, so at most one request per TTL or manual refresh. /login, API-key, Bedrock/Vertex and gateway instances never send it.

    This complements #24128 / #31135 rather than replacing them: streamed unifiedWindows keep the bars current during turns, and the probe covers startup and idle instances. As @TheOriginalOcyrus noted, it spends a sliver of the window it measures, so it may deserve a setting.

Sign in to join this conversation.