Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): Claude usage meter follows live rate-limit updates below the warning threshold #28869

Openjuliusmarmingewants to merge 5 commits intomain fromrefs/pull/28869/headopened View on GitHub

juliusmarmingecommented

Problem

Claude's usage meter falls behind Claude Code's own /usage during active work. The Claude CLI sends a rate_limit_event every time a usage window's whole-percent value changes. Below the warning threshold, though, the per-window readings are only in an untyped unifiedWindows field. The top-level utilization is set only after a warning threshold has been passed. claudeRateLimitEventToUpdate read only the top-level fields, so under normal use it dropped every live frame. The meter then only moved when the 5-minute background provider check ran.

To reproduce: run Claude turns and watch the Session meter while the account is below its warning threshold. The CLI streams new readings, but T3's meter stays at the last probe value.

Change

claudeRateLimitEventToUpdate now decodes unifiedWindows with a Schema and maps each entry onto the rows the probe already creates:

  • five_hour → Session
  • seven_day → Weekly
  • seven_day_overage_included → the row for the model the probe named (still dropped while unnamed)

The top-level bucket is still read for older CLIs that don't send unifiedWindows. When both sources name the same window, the unifiedWindows value wins and no row is duplicated. Contracts, settings, polling and the adapter are unchanged.

Scope and approval

Fixes pingdotgg/t3code#28852

This is a focused fix for a triaged bug in the existing Claude usage-limit stream mapping. It adds no option, contract field or persisted state.

Verification

  • vp test run apps/server/src/provider/claudeUsageLimits.test.ts: 10/10 pass.
    • maps every window in the unifiedWindows the CLI streams below the warning threshold fails on main (expected undefined to deeply equal { windows: [ …(2) ] }) and passes here.
    • keeps one row per window when a warning frame also carries unifiedWindows covers the case where both sources name the same window (no duplicate row) and the overage-included bucket arriving through unifiedWindows.
  • vp run check:changed: format, lint, knip, typecheck (3 packages) and tests pass.

Runtime transcript (server-only fix, no UI change). I ran a real T3 server (t3 serve, fresh database each side) whose Claude provider runs the real Claude CLI 2.1.304, signed in as a synthetic subscriber. The CLI talks to a local stub Anthropic API. The stub returns anthropic-ratelimit-unified-* headers with 5-hour utilization rising 3 points per request and 7-day fixed at 31%, and it answers /api/oauth/usage, so the initial usage probe succeeds. Three turns were driven with t3 thread start --wait. After each step I read Claude's published usageLimits from the provider status cache.

Session meter, stepBefore (main claudeUsageLimits.ts)After (this branch)
initial probe12%12%
after turn 112%15%
after turn 212%21%
after turn 312%27%
unifiedWindows.five_hour frames T3 received0.12 … 0.270.12 … 0.27
Before transcript (main's claudeUsageLimits.ts, blob d0acf43bb4)
initial probe:               checkedAt 2026-11-01T20:09:37.831Z unavailable None windows [('five_hour', 12), ('seven_day', 31)]
after turn 1:                checkedAt 2026-11-01T20:09:37.831Z unavailable None windows [('five_hour', 12), ('seven_day', 31)]
after turn 2:                checkedAt 2026-11-01T20:09:37.831Z unavailable None windows [('five_hour', 12), ('seven_day', 31)]
after turn 3:                checkedAt 2026-11-01T20:09:37.831Z unavailable None windows [('five_hour', 12), ('seven_day', 31)]
stub 5h utilization sent on each /v1/messages response: 0.12 0.15 0.18 0.21 0.24 0.27
rate_limit_event unifiedWindows.five_hour received by T3: 0.12 0.15 0.18 0.21 0.24 0.27
After transcript (this branch, blob 68135fc2e9)
initial probe:               checkedAt 2026-11-01T20:08:09.058Z unavailable None windows [('five_hour', 12), ('seven_day', 31)]
after turn 1:                checkedAt 2026-11-01T20:08:17.017Z unavailable None windows [('five_hour', 15), ('seven_day', 31)]
after turn 2:                checkedAt 2026-11-01T20:08:24.352Z unavailable None windows [('five_hour', 21), ('seven_day', 31)]
after turn 3:                checkedAt 2026-11-01T20:08:31.651Z unavailable None windows [('five_hour', 27), ('seven_day', 31)]
stub 5h utilization sent on each /v1/messages response: 0.12 0.15 0.18 0.21 0.24 0.27
rate_limit_event unifiedWindows.five_hour received by T3: 0.12 0.15 0.18 0.21 0.24 0.27
A frame the CLI sent below the warning threshold, from T3's provider event log
{"status":"allowed","resetsAt":1793576909,"rateLimitType":"five_hour","isUsingOverage":false,"unifiedWindows":{"five_hour":{"utilization":0.18,"resetsAt":1793576909},"seven_day":{"utilization":0.31,"resetsAt":1793994509}}}

The stub, CLI wrapper, TLS proxy and driver scripts are scratch and are not committed. They could not be uploaded because ghdrop is not available in this environment. All data in them is synthetic.

Not verified: a real Claude subscription account (none is available here; the stub reproduces the CLI's documented frames and headers), and a visual check in a client. The fix changes only server-side mapping into the existing provider snapshot, so web, desktop and mobile render it through their existing meter paths.

Model and harness: Claude Opus 5.5 (lead, red test, implementation, review B) and GPT-6.1 Sol (review A) in T3 Code.

🤖 Generated with Claude Code

    1. Pushed3610683

    2. FYI — this still reproduces for me, and it looks like this PR is the actual fix.

      T3 Code 0.1.12-nightly.20261122.5098 (desktop, Linux x64), Claude Code 2.1.330: the Usage page shows only the Codex row, with no claudeAgent row at all.

      I left detailed evidence on #30310: 663 of 933 rate_limit_event messages carry their percentages only in rate_limit_info.unifiedWindows, while claudeRateLimitEventToUpdate still requires top-level utilization. Below the warning threshold (currently ~30% five-hour / ~4% weekly), every event is dropped. #30310 is closed as "Not planned", so tracking the fix here would be useful.

      Please consider reviewing/merging this alongside #31135.

Sign in to join this conversation.