You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(routing): add weighted strategy with smooth weighted round-robin selector
Add a third routing strategy alongside round-robin (default) and
fill-first that distributes traffic across credentials according
to a configurable weight per key. The new WeightedSelector uses
the smooth weighted round-robin algorithm popularized by nginx
(Wensong Zhang) so weights like 7:3 yield an interleaved 7:3 share
without long runs on any single credential.
Each key type (ClaudeKey, CodexKey, GeminiKey, OpenAICompatibility,
VertexCompatKey) gains an optional 'weight' field that the
synthesizer propagates to auth.Attributes['weight']. Missing,
non-positive, or unparsable weights coerce to 1 so a misconfigured
credential still participates fairly. Priority remains a strict
tier above weight - high-priority credentials are exhausted before
weights inside lower tiers are considered.
Wire the strategy through builder.go, service.go hot reload, and
the management API normalize function. The selector is intentionally
not registered as a built-in selector so the conductor's legacy
pick path drives it directly, keeping the scheduler fast-path
unchanged.
Documented in config.example.yaml. Covered by 9 unit tests in
sdk/cliproxy/auth/weighted_selector_test.go including the canonical
SWRR sequence, ratio convergence over 1000 picks, default-weight
behavior, priority dominance, per-route state isolation, and a
concurrency stress test.
0 commit comments