Claude accounts: switch a chat refused for usage to another saved account and continue it

When Claude Code refuses an operator chat's turn for a usage limit, the
server marks the refused account until its reset and, if the chat's Claude
home allows it (claude_account_auto_switch / `pipelines claude-account auto
on|off`, on by default, kept in pipelines-accounts/settings.json), switches
the home to the saved account with the most usage left through the
claude_account_use path. Switches of one home are serialized, so chats
refused together switch once. Each refused chat gets one queued prompt,
marked as sent automatically, that asks the agent to check it is on track
before continuing; the app's auto-continue-at-reset prompt for the refusal is
removed (and refused if it arrives later), and the operator gets a
low-priority notification.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 00:23:43 +00:00
parent 1995382e8c
commit ed9072b79a
30 changed files with 1362 additions and 21 deletions
+10
View File
@@ -20,6 +20,10 @@ const (
// ClaudeAccountRemove deletes the saved account Name. The active login is
// unchanged.
ClaudeAccountRemove = "claude_account_remove"
// ClaudeAccountAutoSwitch sets whether a chat on this Claude home that
// runs out of usage is switched to another saved account with usage left
// and continued automatically (AutoSwitch; on by default).
ClaudeAccountAutoSwitch = "claude_account_auto_switch"
)
// ClaudeAccountRequest is the body of every claude_account* request.
@@ -28,6 +32,9 @@ type ClaudeAccountRequest struct {
// Name is the saved account (its name, slug or email); for a save, the
// name to save under ("" uses the email).
Name string `json:"name,omitempty"`
// AutoSwitch is the new automatic-switch choice of a
// claude_account_auto_switch request.
AutoSwitch *bool `json:"auto_switch,omitempty"`
}
// ClaudeAccount describes one Claude login without its credentials.
@@ -54,4 +61,7 @@ type ClaudeAccountList struct {
// Usage is the newly active account's latest known quota after a
// claude_account_use (see ChatAccountUsage.SwitchedAt).
Usage *ChatAccountUsage `json:"usage,omitempty"`
// AutoSwitch reports whether running out of usage switches the Claude
// home to another saved account and continues the chat automatically.
AutoSwitch bool `json:"auto_switch"`
}