From 2bb211c979791260e4a3569f94f0c4dc2e787f4f Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sat, 21 Feb 2026 02:27:27 +0900 Subject: [PATCH] fix: add max retry protection and session cleanup for model fallback --- src/shared/model-error-classifier.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/shared/model-error-classifier.ts b/src/shared/model-error-classifier.ts index 9ff47fb5..7cbebca3 100644 --- a/src/shared/model-error-classifier.ts +++ b/src/shared/model-error-classifier.ts @@ -55,6 +55,8 @@ const RETRYABLE_MESSAGE_PATTERNS = [ "504", ] +const MAX_FALLBACK_ATTEMPTS = 10 + export interface ErrorInfo { name?: string message?: string @@ -108,7 +110,10 @@ export function hasMoreFallbacks( fallbackChain: FallbackEntry[], attemptCount: number, ): boolean { - return attemptCount < fallbackChain.length + return ( + attemptCount < fallbackChain.length && + attemptCount < MAX_FALLBACK_ATTEMPTS + ) } /**