mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-06 23:32:12 +03:00
fix(resilience): honor model lockout max cooldown
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
DEFAULT_RESILIENCE_SETTINGS,
|
||||
resolveResilienceSettings,
|
||||
} from "../../src/lib/resilience/settings";
|
||||
import { resolveModelLockoutSettings } from "../../src/lib/resilience/modelLockoutSettings";
|
||||
import {
|
||||
getAllCircuitBreakerStatuses,
|
||||
getCircuitBreaker,
|
||||
@@ -37,6 +38,7 @@ export type ProviderProfile = {
|
||||
useUpstreamRetryHints: boolean;
|
||||
/** Issue #2100 follow-up. Stored override; undefined → per-provider default. */
|
||||
useUpstream429BreakerHints?: boolean;
|
||||
maxCooldownMs: number;
|
||||
maxBackoffSteps: number;
|
||||
failureThreshold: number;
|
||||
resetTimeoutMs: number;
|
||||
@@ -326,6 +328,7 @@ function buildProviderProfile(
|
||||
// Issue #2100 follow-up: propagate stored override (boolean | undefined)
|
||||
// so the runtime resolver picks user setting first, then per-provider default.
|
||||
useUpstream429BreakerHints: connectionCooldown.useUpstream429BreakerHints,
|
||||
maxCooldownMs: resolveModelLockoutSettings(settings).maxCooldownMs,
|
||||
maxBackoffSteps: connectionCooldown.maxBackoffSteps,
|
||||
failureThreshold: providerBreaker.failureThreshold,
|
||||
resetTimeoutMs: providerBreaker.resetTimeoutMs,
|
||||
|
||||
@@ -1916,6 +1916,7 @@ export async function markAccountUnavailable(
|
||||
const disableCooling = connProviderSpecificData.disableCooling === true;
|
||||
|
||||
const isPerModelQuotaProvider = hasPerModelQuota(provider, model, connectionPassthroughModels);
|
||||
const modelLockoutOptions = { maxCooldownMs: effectiveProviderProfile?.maxCooldownMs };
|
||||
if (
|
||||
isPerModelQuotaProvider &&
|
||||
provider &&
|
||||
@@ -1942,6 +1943,7 @@ export async function markAccountUnavailable(
|
||||
: (fallbackResult.baseCooldownMs ?? effectiveProviderProfile?.baseCooldownMs ?? 0),
|
||||
effectiveProviderProfile,
|
||||
{
|
||||
...modelLockoutOptions,
|
||||
exactCooldownMs:
|
||||
fallbackResult.usedUpstreamRetryHint === true ? fallbackResult.cooldownMs : null,
|
||||
maxCooldownMs: mlSettings.maxCooldownMs,
|
||||
@@ -2019,6 +2021,7 @@ export async function markAccountUnavailable(
|
||||
COOLDOWN_MS.serviceUnavailable,
|
||||
effectiveProviderProfile,
|
||||
{
|
||||
...modelLockoutOptions,
|
||||
exactCooldownMs:
|
||||
fallbackResult.usedUpstreamRetryHint === true ? fallbackResult.cooldownMs : null,
|
||||
maxCooldownMs: mlSettings.maxCooldownMs,
|
||||
|
||||
Reference in New Issue
Block a user