Skip to content

[Feature] Keep and expose Claude's per-session rate_limit_event (5h/7d utilization) instead of dropping it #35497

Open

Description

@tcmyers

Setup

Orca on macOS running Claude Code native chats with several managed Claude accounts (own subscriptions). An external tool moves the active account when a usage window nears its limit (Orca's own accounts.selectClaude is not used, because running sessions would stall).

Problem

Every Claude Code response already carries the account's 5-hour and 7-day utilization, and Claude Code prints it to Orca as a rate_limit_event frame on its stream-json stdout (rate_limit_info.unifiedWindows.{five_hour,seven_day}.{utilization,resetsAt}, present after the first response of a subscription session). Orca reads the frame (src/main/claude/claude-usage-limits.ts, observe()) but keeps only a rejected flag per window to word a failure row; the frame is classified status-chrome and is not journaled. So the freshest usage signal a host can have is dropped, and anything that wants it has to poll /api/oauth/usage, which 429-locks at a few calls an hour per token.

Request

Keep the last rate_limit_event per session and expose it, either:

  1. in the session record / journal (for example the last unifiedWindows with the frame's receive time), or
  2. on the local socket (accounts.list already has a rateLimits object; per-session or per-account windows fed from the frame would make it accurate for active accounts without any request), or
  3. as a hook/event, which also covers request 4 of [Feature] Switch running Claude sessions to the new account on a headless/remote host (account switch via RPC/CLI, usage-limit event) #31476.

No request to Anthropic is needed for any of these: the data is already in the stream Orca receives.

Why it matters

With dozens of sessions running, usage moves faster than any polling interval. A host-side switch or a pause decision made from the frame happens within one turn; from polling it happens minutes later, after sessions have already hit the limit.

Related

#31476 (request 4), #12098.

Activity

  1. william7211 commented on Nov 17, 2026

    @william7211

    +1 — adding a Windows / claude setup-token case where this frame is the only usage source available.

    Setup: Orca 1.4.261, Windows 11, Claude Code 2.1.326, Max plan. Auth is a claude setup-token token in CLAUDE_CODE_OAUTH_TOKEN (to avoid recurring re-logins). ~/.claude/.credentials.json only holds an ended login (accessToken: "", loginEnded: "time_limit").

    What happens:

    • The status bar shows no Claude usage. From the shipped bundle, the win32 usage path only reads .credentials.json (no keychain); with an empty access token and no refresh token under system provenance it returns unavailable ("No subscription plan — API key billing") without any fallback.
    • CLAUDE_CODE_OAUTH_TOKEN isn't consulted by that path, and a setup token only has user:inference anyway, so /api/oauth/usage can't serve it (see [Feature]: Support claude setup-token for managed Claude accounts #12002).
    • Claude Code itself does show the windows for this sign-in — /usage: "Current session 55% used / Current week (all models) 25% used — Other limits and usage credits aren't shown for this sign-in." So 5h/7d data reaches the client on normal responses.

    Feeding the status bar (and accounts.list rateLimits) from the last rate_limit_event would turn "nothing" into accurate 5h/7d bars for setup-token users, with no extra requests. Possible order: OAuth usage API when a full-scope token exists → last rate_limit_event otherwise.

    Related: #12002

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