fix: treat Kiro 400 'improperly formed request' as model-unavailable (#386)

Kiro returns HTTP 400 with 'Improperly formed request (reset after Xs)'
when a model is not available on that account's subscription tier.
Previously this fell through to COOLDOWN_MS.transient (30s), causing
rapid retries on all accounts before failing — all accounts get locked
simultaneously with no actual fallback.

Treating this as paymentRequired (2min cooldown) ensures:
1. The model is locked on that account for 2min (proper cooldown)
2. The next available account is tried immediately
3. If all accounts hit the same 400, 9Router falls through to the
   next provider in the combo

Fixes #384
This commit is contained in:
Anurag Saxena
2026-03-22 22:31:31 -04:00
committed by GitHub
parent af247fb6ac
commit b8918c0c1c

View File

@@ -32,6 +32,12 @@ export function checkFallbackError(status, errorText, backoffLevel = 0) {
return { shouldFallback: true, cooldownMs: COOLDOWN_MS.requestNotAllowed };
}
// Kiro: "improperly formed request" = model not available on this account tier
// Treat as paymentRequired (long cooldown) so the model is locked and fallback occurs
if (lowerError.includes("improperly formed request")) {
return { shouldFallback: true, cooldownMs: COOLDOWN_MS.paymentRequired };
}
// Rate limit keywords - exponential backoff
if (
lowerError.includes("rate limit") ||