fix(auth): mirror session affinity retention and sticky fallback - #197
fix(auth): mirror session affinity retention and sticky fallback#197warelik wants to merge 1 commit into
Conversation
Retain session affinity across transient errors (5xx, 429, timeouts, Cloudflare challenges) so requests return to warm prompt caches upon recovery. Maintain sticky fallback during primary cooldown and clear temporary fallback bindings when the primary credential recovers. Mirror upstream CLIProxyAPI PR #5109 (commits 5a4f2086, 31f1ff8c, 15b22675, f174bf68).
|
Closing this PR — the branch is the wrong shape for this repository and should not be merged as-is. What this branch actually does against It deletes Context on how this happened: the change was derived from the equivalent work in the upstream repository (router-for-me/CLIProxyAPI#5109). This repository's Next step on our side: verify against this repository's current Apologies for the noise. |
Summary
Mirror upstream CLIProxyAPI PR #5109 (session affinity retention across transient errors and sticky fallback during cooldown).
Problem
Previously, transient errors (HTTP 5xx, 429 rate limits, request timeouts, and Cloudflare challenge responses) purged session-affinity bindings from cache or applied a blanket 5-second session quarantine. This evicted warm prompt caches prematurely and caused unnecessary credential rotations across requests. Furthermore, during credential cooldown, fallback selection did not maintain stickiness across requests sharing session aliases.
Fix
fallbackCacheinSessionAffinitySelectorto provide sticky fallback credentials across session aliases during primary cooldown.Testing
sdk/cliproxy/auth/session_affinity_retention_test.go:TestSessionAffinity_Transient503RetainsBindingAcrossRecoveryTestSessionAffinity_Transient429RetryAfterRetainsBindingAcrossRecoveryTestSessionAffinity_Terminal401InvalidAPIKeyUnbindsSessionTestSessionAffinitySelector_OnResult_TransientVsTerminalClassificationTestSessionAffinity_StickyTemporaryFallbackDuringPrimaryCooldownTestSessionAffinity_StickyTemporaryFallbackTTLExpiryTestSessionAffinity_StickyTemporaryFallbackSharedAcrossAliasesTestSessionAffinity_StickyTemporaryFallbackSecondaryBranchTestSessionAffinity_ModelFallbackSuffixDoesNotCollideWithTemporaryFallbackgo test -count=1 ./...go vet ./sdk/cliproxy/auth/...Mirror
5a4f2086,31f1ff8c,15b22675,f174bf68