fix(resilience): honor model lockout max cooldown

This commit is contained in:
KooshaPari
2026-06-26 05:00:14 -07:00
parent e4fef27aac
commit 0bc232693f
2 changed files with 6 additions and 0 deletions

View File

@@ -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,

View File

@@ -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,