Repository navigation
Conversation
Oversized payloads (>=50k tokens) or TPM 429s can trigger a cascade where cross-pool retries repeatedly extend key cooldowns and trip the long model-lockout. This guard suppresses cross-pool fallback for identified avalanche risks and bounds the transient key cooldown, without tripping the 1800s lockout, so a single heavy request cannot avalanche the whole pool.
|
Hi @ggdayup — closing this pull request to clear the open queue. The branch |
|
Hi @ggdayup — reopening this pull request. The close was a mistake, and it is back in the merge queue. The branch |
|
Thanks for this, @ggdayup. Short-circuiting 413 and context-overflow 400s makes sense to me. One concern about the size-only 429 branches, from a gateway I run: our agent traffic sends prompts that routinely sit above the 50k threshold through a pool of Gemini keys, and most of the 429s on those are the daily quota, not TPM. Of the 646 retry hints Gemini put in 429 bodies between Oct 9 and 12, 488 were longer than 1 h, up to 86,399 s (the numbers in #16525). On the PR head (297d4d5), branch 3c of The 115,618-token "incident repro" test uses the generic "Resource has been exhausted (e.g. check quota)." text with no retry hint, which Would two small changes work for you when you rebase for 3.8.53?
A test with a 60k-token prompt and a Gemini body whose message says Two related changes, for context. #16360, merged today, waits out a short transient model lock that would otherwise skip every target before dispatch ( One more thing for the rebase: on today's Happy to run the rebased branch against the same traffic and report the lockout durations back here. |
|
Re-homed to |
…bs, guard avalanche headers - 413 keeps the cheaper-inference#13350 retry-on-another-account contract (no longer suppressed) - drop the generic token_count / exceeded.*token.*quota TPM patterns - tuning is env-only (OMNIROUTE_AVALANCHE_*), documented in .env.example and ENVIRONMENT.md - best-effort suppression headers (immutable Response headers no longer throw) - add chat pipeline wiring tests and a changelog fragment
…-complexity threshold Extract the HTTP 429 branch and the no-risk result into helpers so the new function no longer adds a cognitive-complexity ratchet violation (17 > 15). Behaviour is unchanged; the 18 anti-avalanche tests stay green. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
What
Adds a payload-aware anti-avalanche guard so a single oversized request cannot avalanche the whole provider pool. On an identified avalanche risk (>=50k prompt tokens or a TPM-class 429) the guard suppresses cross-pool fallback (
shouldFallback: false), bounds the per-key transient cooldown viaavalancheCooldownMs, and deliberately skips the 1800s model-lockout path so a heavy prompt on one key does not blackhole the model for 30 minutes.Why
The existing resilience layers (connection cooldown, provider circuit-breaker, model lockout) do not recognise that an oversized payload failing repeatedly across pools is an avalanche rather than a normal 429. Without this, one heavy client can exhaust every pool's headroom at once.
Scope
open-sse/services/accountFallback/antiAvalanche.ts(risk classification + bounded cooldown)src/sse/services/auth.ts: options surface (isAvalancheRisk,avalancheCooldownMs,suppressFallback),exactCooldownMsavalanche-first precedence, early return whensuppressFallbacksrc/sse/handlers/chat.ts: wire the classifier into the request pipelinetests/unit/anti-avalanche-failover-protection.test.ts— 12 assertionsTest evidence
node --import tsx/esm --test tests/unit/anti-avalanche-failover-protection.test.ts-> 12/12 pass on this branch.⚠ base-red inherited: #15306