[Feature]: Switch Claude accounts automatically near their usage limit
Problem or use case
With several saved Claude accounts, Orca only switches between them when I do it by hand. When the active account runs into its 5-hour or weekly limit mid-task, I usually notice late and have to stop, open Settings > Accounts, and pick another account.
Proposed solution
An opt-in setting under Settings > Accounts > Claude that switches the active account automatically when its usage reaches a threshold (default 90%):
- The next account is the one with the highest priority that is still under its own threshold; ties go to the one with the most quota left.
- Each account can be taken out of rotation and given its own threshold and priority.
- Switching goes through the existing account selection path, with a short cooldown so a stale reading cannot bounce between accounts.
Alternatives or additional context
Switching manually works today. Other multi-account tools for Claude Code offer the same kind of automatic switching based on usage; strategies beyond "priority, then most quota left" could be added later.
+1, with notes from running this ourselves. We have used an external script that does exactly this on macOS (Orca 1.4.263) for about a month: 2 Orca-managed Claude accounts and 2 claude setup-token accounts, with 10–20 Claude tabs and Orca chat windows open at once. Some things we learned that may help the design:
What has worked
- A priority list with a 5-hour threshold and an optional weekly threshold per account. The weekly one matters: an account at 96% weekly still looks free in its 5-hour window, but it runs out mid-task.
- Switching back when a higher-priority account recovers (5-hour reset). Without that, usage drifts onto the lowest-priority account and stays there.
- Applying the switch to running tabs: end +
--resume, then a short "continue" prompt for tabs that were mid-turn. Idle tabs, and tabs waiting on a background shell, need the same treatment, or they wake up later on the exhausted account (#40263). - Reading usage from the data sessions already receive (statusline /
rate_limit_event, #35497), and polling/api/oauth/usageonly when there is no fresh value. Polling from every tab got us 429s, so we share one result per account for 5 minutes.
Problems we hit
- Two sources of truth fight. When the switcher's choice and the account selected in Orca's UI differ, a restarted Orca chat window comes back on the UI account. The switcher then sees it on the "wrong" account and restarts it again. That loop killed a chat every ~5 minutes (exit 143) until we also called
orca account select. A built-in feature avoids this by design, but every restart path (terminal tabs, native chats, bots: #45478, #46233) needs to read the same selection. - Idle accounts can't report usage. An Orca-managed account that nobody used for ~8 hours has an expired access token, so its usage can't be read without a refresh. Refreshing from outside Claude Code risks rotating the single-use refresh token out from under Orca (#12002, #6234). Our workaround is a 1-token
claude -pon that account, so Claude Code refreshes it itself. If Orca kept stored accounts fresh, a switcher could rank idle accounts correctly. - setup-token accounts can't be added to Orca (#12002), so they can't join a built-in rotation. They also can't call
/api/oauth/usage(inference scope only). We read their usage from theanthropic-ratelimit-unified-*headers of a 1-token request.
Happy to test a PR on macOS with this setup.
One more use case, plus one detail on how the next account should be picked.
I run six Claude accounts in Orca 1.4.279. Right now one is at 57% of its weekly limit, one at 38%, one at 96% and three at 100%, and one of the full ones resets tomorrow morning. Switching is by hand, so the selected account usually hits its limit before anyone notices, and the chats on it stop.
On picking the next account: please look at reset times as well as the usage now. An account that is at 100% but resets in ten minutes, or has just reset, often has more room for the rest of the day than one sitting at 60% of its weekly limit. Orca already reads each account's 5-hour and weekly reset times (src/main/claude/structured/journal/claude-usage-limits.ts), so the choice could prefer:
- accounts under the threshold on both the 5-hour and the weekly limit, most weekly headroom first;
- otherwise, the account whose limit resets soonest.
Related: #46761 asks for the same switch (default 95%), #44687 for resuming a limited chat on the first account with room, #33193 for a priority order with switching back after a reset, #20512 for the wider failover.