From ee78761544f9fc1ffa7750744c27fdd982afbc0e Mon Sep 17 00:00:00 2001 From: BlackBearCC Date: Fri, 30 Jan 2026 10:00:56 +0800 Subject: [PATCH] fix: ensure model failover works across different providers --- src/agents/model-fallback.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/agents/model-fallback.ts b/src/agents/model-fallback.ts index b87135f9f..d5ad8e80e 100644 --- a/src/agents/model-fallback.ts +++ b/src/agents/model-fallback.ts @@ -234,14 +234,17 @@ export async function runWithModelFallback(params: { const isAnyProfileAvailable = profileIds.some((id) => !isProfileInCooldown(authStore, id)); if (profileIds.length > 0 && !isAnyProfileAvailable) { - // All profiles for this provider are in cooldown; skip without attempting - attempts.push({ - provider: candidate.provider, - model: candidate.model, - error: `Provider ${candidate.provider} is in cooldown (all profiles unavailable)`, - reason: "rate_limit", - }); - continue; + // Only skip if this provider is the same as the original one to ensure fallbacks to other providers are still tried + const originalProvider = candidates[0]?.provider; + if (candidate.provider === originalProvider) { + attempts.push({ + provider: candidate.provider, + model: candidate.model, + error: `Provider ${candidate.provider} is in cooldown (all profiles unavailable)`, + reason: "rate_limit", + }); + continue; + } } } try {