This repository was archived by the owner on Sep 30, 2026. It is now read-only.
Repository navigation
feat(usage): pace-aware multi-account rotation with revoked-account auto-failover - #8
Merged
Merged
Conversation
…t just 401 A revoked or invalidated Anthropic OAuth account fails during token refresh, so its error surfaces with no bare 401/403 status literal - only an OAuth `invalid_grant` code or a "token revoked"/"refresh failed" phrase (e.g. "Claude OAuth token is expired and refresh failed: invalid_grant"). The same-provider account failover is gated on classify_failover_error_message, which previously matched only "unauthorized"/"authentication failed"/401/403. A revoked account therefore classified as None, the failover never fired, and the turn dead-ended at the "/poke to resume" stall instead of rotating to a healthy account. Add invalid_grant, authentication_error, token-revoked, and refresh-failed needles to the auth/access bucket so a revoked account fails over the same way a 429 usage-limit already does: mark it unavailable and retry on the next healthy account, then resend. Covered by a new classifier test over the real revoked-error strings.
yjuyjuy
force-pushed
the
pace-aware-account-switching
branch
from
August 11, 2026 14:35
8b34ea9 to
3577358
Compare
This was referenced Aug 13, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
When an Anthropic account's OAuth is revoked, every jcode worker pinned to it hits a 401
authentication_error(OAuth token revoked; automatic refresh fails withinvalid_grant) and stalls at the "last request failed in a way retrying won't fix, /poke to resume" prompt. It does not auto-fail-over to another healthy account inauth.json. Recovery today is fully manual per pane (Escape,/account claude switch <live-label>,/poke), so a routine credential revocation silently wedges the whole fleet.This is distinct from the 429 usage-limit fallback: a revocation is an auth error (401 /
invalid_grant), not a usage signal, so any pace/usage-based auto-switch never triggers on it.What this branch delivers
Two complementary halves of the same multi-account rotation:
Pace-aware multi-account balancing and priming (existing commit): proactively consumes the soonest-resetting weekly window first and primes cold accounts, so perishable quota is not wasted. Fires on usage-limit / 429 pressure.
Revoked/invalid-grant auto-failover (new): a revoked account fails during token refresh, so its error carries no bare 401/403 status literal - only an OAuth
invalid_grantcode or a "token revoked" / "refresh failed" phrase.classify_failover_error_messagepreviously matched onlyunauthorized/authentication failed/ 401 / 403, so a revoked account classified asNoneand the existing same-account failover never fired. This addsinvalid_grant,authentication_error, token-revoked, and refresh-failed needles to the auth/access bucket, so a revoked account fails over exactly like a 429 does: mark it unavailable, retry on the next healthy account, then resend.Net effect: failover now triggers on both usage-limit (429) and auth/revoked (401 /
invalid_grant) errors, to the next healthy account, then resends - instead of dead-ending at the/pokestall.Tests
classifier_fails_over_on_revoked_oauth_without_status_codeover the real revoked-error strings.cargo test -p jcode-provider-core failovergreen (5 passed).cargo build -p jcode-provider-core -p jcode-baseandcargo clippy -p jcode-provider-coreclean.Operational note (not code)
Desired live rotation is claude-2 ([email protected]) as primary, auto-switching to claude-1 ([email protected]) on limit or auth failure. The active-account choice is a runtime credential flip in
~/.jcode/auth.jsonaffecting every running session, deliberately left out of this code change.