[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
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#
- Create a token with
claude setup-tokenand a wrapper script that exports CLAUDE_CODE_OAUTH_TOKEN and execsclaude. Register the wrapper as a Claude provider instance (binaryPath). Repeat for a second account. - Use both instances normally.
- 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
Liri-s29(GitHub profile, opens in a new tab) added labelsbug
Liri-s29(GitHub profile, opens in a new tab) added labelsneeds-triage
Same here, with some measurements that may help.
Setup: several Claude subscriptions on one host, each instance signed in with a
claude setup-tokentoken (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_usageanswersrate_limits_available: false,rate_limits: nullunder a setup-token, so the instance is marked unsupported until a session streams arate_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_eventwith both windows inunifiedWindows: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 onlyseven_daywhile 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:
- Keep the last
rate_limit_eventlimits when the provider check comes back unsupported, instead of replacing them (this looks like what #31135 does, so +1 to that). - 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.- On a subscription already at its weekly limit, the turn errors but the event still arrives (
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_TOKENis 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 })returnsrate_limits_available: false,rate_limits: null.tokenSourceisCLAUDE_CODE_OAUTH_TOKENandsubscriptionTypeis empty. - During turns, the provider event log gets
rate_limit_eventwithunifiedWindows.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.- The provider check's
+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_TOKENin the service environment. I have more data on the cold-start part (no recentrate_limit_event), plus a cheaper way to take a reading than aclaude -pturn.Why each source fails with a default setup-token (scope
user:inference):get_usagereturnsrate_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→ 403oauth_scope_insufficient(required_scopes: ["user:profile"]).- Requests that cost nothing don't help.
/v1/messages/count_tokensand invalid requests (max_tokens: 0, emptymessages, unknown model) come back without the unified headers.
What works: any accepted
/v1/messagesrequest returnsanthropic-ratelimit-unified-{5h,7d}-{utilization,reset}headers (0-1 fractions, epoch-second resets). The CLI's own/usagescreen 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 -pturn 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. Aclaude-cliuser-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 noANTHROPIC_BASE_URL, andget_usagereportedrate_limits_available: false, send that request once and map the headers into theget_usageshape. The existingclaudeUsageResponseToLimitsand 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
unifiedWindowskeep 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.
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_usagesaysrate_limits_available: false. When auth comes fromCLAUDE_CODE_OAUTH_TOKEN, Claude Code gives the token the scopes inCLAUDE_CODE_OAUTH_SCOPES, or["user:inference"]if that is unset.get_usageonly reads plan limits when the scopes includeuser: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 flipsget_usagetorate_limits_available: true, butrate_limitsstaysnull. All three tokens get HTTP 429 from/api/oauth/usagewithretry-after: 3596(a bogus token gets 401, so they do authenticate). T3 then marks the probeprobeFailed, and the streamed windows are still dropped, because the event only hasunifiedWindowsand no top-levelutilization:So a user can't work around this. It needs both parts of #24128: the setup-token
probeFailedpath and theunifiedWindowsparsing.