Repository navigation
feat(accounts): automatic Claude account failover on the 5-hour limit - #1250
Open
fabianthegiant wants to merge 1 commit into
Open
fabianthegiant wants to merge 1 commit into
fabianthegiant wants to merge 1 commit into
Conversation
Settings → Accounts gains "Automatic Claude failover": a primary and a secondary local Claude account. While the primary is in its 5-hour session limit, idle local Claude sessions on it move to the secondary through the existing "Switch Claude account" choreography (quit, copy transcript, rebind, recycle + resume), and move back once the primary is free again. Only a fresh usage read decides. A weekly-limited primary, a limited or unreadable secondary, busy sessions, SSH nodes and relay tabs never move. Moved nodes carry a persisted `claudeFailover` mark so only they return, and a manual switch clears it. Off by default; works on the desktop and in a Server Edition browser tab (only a visible tab acts). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
We heavily use claude team plan and only have 5h limit. For claude to run indefinitely I want to use 3 Team plans in parallel. For that I've expanded your already existing account switching feature and added limit detaction and automatic switching of accounts. I released it under the branch feat/claude-account-failover. If you think that is usefull please merge that into main would greatly appriciate it! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a Claude account hits its 5-hour session limit, every session on it stops until the window resets, even if a second logged-in account is free. This adds an opt-in failover: pick a primary and a secondary account in Settings → Accounts. While the primary is in its 5-hour limit, its idle local Claude sessions move to the secondary and continue the same conversation. Once the primary is free again, exactly those sessions move back.
Every move is the existing "Switch Claude account" choreography (
runClaudeAccountSwitch: quit, copy the transcript, rebind, recycle +--resume), so no new switching path exists.Behaviour
okusage read decides (failoverLimitState). Error, held last-good numbers or a missing session window meansunknown, and nothing moves.working/blocked) sessions, SSH nodes or SSH projects, relay tabs. A model-scoped weekly cap does not count as a weekly limit.data.claudeFailovermark, so the way back survives a restart and only those nodes return. A manual switch clears the mark: thebeforeRecyclepatch always carries the key, which isundefinedon a manual switch.usage.fetch(primary), which the usage service mostly answers from its 5-min cache. There is one forced refresh once the session reset time has passed (at most every 2 min). The secondary is read only when a move is due.settings.claudeFailoverin machine-localsettings.json, re-validated on read (resolveFailover), so a malformed value reads as off.Surfaces
usage.fetchandclaudeAccounts.copySession. It runs only while a tab is open, and only a visible tab acts, so two tabs do not both switch one session. Headless installs have no tab, so they do not fail over.Why renderer-side
The switch choreography (the CLI exit, the restart closure, the
beforeRecyclemerge) lives in the renderer. A core-side watcher would need a second, headless switch path. I chose to reuse the existing one, at the cost of needing an open window or tab. Moving it to core, so a headless server fails over without a tab, is the obvious follow-up.How it was checked
npm run typecheck,npm run buildand the fullnpm testpass locally (1626 files passed, 9 skipped).src/renderer/canvas/claude-failover.test.tscover settings validation, limit classification and the move/return planning, including every no-move edge case.Not verified: a live run with two real accounts actually hitting the 5-hour limit (detection, the move and the move back in a running app), the Server Edition tab-visibility gating in a real browser, and macOS/Windows.
Known limits
Docs:
docs/claude-account-failover.md(user-facing) and a bullet under Managed Claude accounts inCLAUDE.md.🤖 Generated with Claude Code