Repository navigation
Route across logins and keys with CPA's strategies, retries and cooldowns - #24
Merged
Merged
Conversation
…owns Each Claude and ChatGPT login is now a candidate of its own, so a request moves on to the next login when one is rate limited or failing, as it already did for API keys. The new free/src/routing.ts follows CPA's auth conductor: round-robin, weighted-round-robin and fill-first strategies, request-retry rounds with max-retry-credentials and max-retry-interval, and cooldowns (Retry-After and provider reset hints, the 1 s to 30 min quota backoff, 30 min for 401/402/403 keys, 12 h for 404, 60 s for transient errors), with disable-cooling and request-retry overrides per key and per login. Isolates share cooldowns through the Durable Object, the Auth Files list shows them in CPA's shape, and the dashboard's reset button clears them.
…-foif0l # Conflicts: # free/README.md # free/src/account.ts # free/src/app.ts # free/src/management.ts # free/src/providers.ts # free/test/management.test.ts
…-foif0l # Conflicts: # free/README.md # free/src/account.ts # free/src/app.ts # free/test/app.test.ts
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.
Requested by PlaygrndLabs · project thread
What this does
Item 4 of the plan (routing polish) for the Workers-only install, following CPA's auth conductor (
sdk/cliproxy/auth) and its v8 config.priority,weight,prefix,disable_coolingandrequest_retryfrom their auth file, as CPA does.routing.strategy):round-robin(default),weighted-round-robinandfill-first, within the highest priority, with lower priorities as fallbacks.routing.retry.request-retry,max-retry-credentials,max-retry-interval), with per-key and per-loginrequest-retryoverrides. A later round waits for the soonest cooldown only if it ends withinmax-retry-interval.free/src/routing.ts), with CPA's durations: 429 waits for the provider's stated reset (Retry-After, Anthropic's rejected unified window, Codexusage_limit_reached, GeminiRetryInfo), with a 10 s floor, or else CPA's 1 s → 30 min backoff. 401/402/403 on a key rest it for 30 min, 404 rests that model for 12 h, and transient errors rest it for 60 s (cooldown.transient-error-cooldown-seconds).disable-coolingworks globally, per key and per login. If every credential is cooling, the client gets a 429 withRetry-Afterand no upstream call is made.cooldowns,unavailable,next_retry_afterand status in CPA's shape (checked against the latest panel's parser), andPOST /v8/management/routing/cooldown/resetreally clears them now.Behaviour changes to note
round-robin, key weights no longer skew turns: CPA only uses weights underweighted-round-robin. Weight 0 now takes a key out of weighted rotation, as in CPA.Limits
At most 10 upstream attempts and 2 minutes of waiting per request, to stay inside the Free plan's 50 subrequests.
Security pass
/v8/managementroute.cool()is reachable only over the Worker→DO binding. It is still bounded: 200 events, length caps, at most 24 h, backoff level capped.Tests
npm run verify: typecheck, lint and 178 tests pass. New tests cover login failover, cooldown sharing, all-cooling 429, the last error returned whole, no failover on 400, retry rounds with a wait,max-retry-interval, priority anddisable-cooling, prefix logins, ChatGPT login failover, reset, the DO's routing state and the management views.Generated by Claude Code