Merge pull request #1136 from cheeeee/fix/prompt-failover

fix(agent): Enable model fallback for prompt-phase quota/rate limit errors
This commit is contained in:
Peter Steinberger 2026-01-18 03:32:03 +00:00 committed by GitHub
commit 5fa1a63978
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -318,6 +318,19 @@ export async function runEmbeddedPiAgent(
thinkLevel = fallbackThinking;
continue;
}
// FIX: Throw FailoverError for prompt errors when fallbacks configured
// This enables model fallback for quota/rate limit errors during prompt submission
const promptFallbackConfigured =
(params.config?.agents?.defaults?.model?.fallbacks?.length ?? 0) > 0;
if (promptFallbackConfigured && isFailoverErrorMessage(errorText)) {
throw new FailoverError(errorText, {
reason: promptFailoverReason ?? "unknown",
provider,
model: modelId,
profileId: lastProfileId,
status: resolveFailoverStatus(promptFailoverReason ?? "unknown"),
});
}
throw promptError;
}