From 712dc245ac6b59a1c15716a5f2b7250b6824b452 Mon Sep 17 00:00:00 2001 From: Sandy Tao Date: Mon, 22 Sep 2025 17:15:55 -0700 Subject: [PATCH] fix(quality): Retry invalid stream only 1 time (#9169) --- packages/core/src/core/geminiChat.test.ts | 6 +++--- packages/core/src/core/geminiChat.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/core/geminiChat.test.ts b/packages/core/src/core/geminiChat.test.ts index d85609fec5..6e997ec9b1 100644 --- a/packages/core/src/core/geminiChat.test.ts +++ b/packages/core/src/core/geminiChat.test.ts @@ -891,11 +891,11 @@ describe('GeminiChat', () => { } }).rejects.toThrow(InvalidStreamError); - // Should be called 3 times (initial + 2 retries) + // Should be called 2 times (initial + 1 retry) expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes( - 3, + 2, ); - expect(mockLogContentRetry).toHaveBeenCalledTimes(2); + expect(mockLogContentRetry).toHaveBeenCalledTimes(1); expect(mockLogContentRetryFailure).toHaveBeenCalledTimes(1); // History should be clean, as if the failed turn never happened. diff --git a/packages/core/src/core/geminiChat.ts b/packages/core/src/core/geminiChat.ts index 8088facb94..855ecc51ea 100644 --- a/packages/core/src/core/geminiChat.ts +++ b/packages/core/src/core/geminiChat.ts @@ -63,7 +63,7 @@ interface ContentRetryOptions { } const INVALID_CONTENT_RETRY_OPTIONS: ContentRetryOptions = { - maxAttempts: 3, // 1 initial call + 2 retries + maxAttempts: 2, // 1 initial call + 1 retry initialDelayMs: 500, };