Skip to content

Commit 3b97772

Browse files
sehoon38Adib234
authored andcommitted
Set default max attempts to 3 and use the common variable (#18209)
1 parent 065acea commit 3b97772

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

packages/core/src/core/geminiChat.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ import type {
1818
} from '@google/genai';
1919
import { toParts } from '../code_assist/converter.js';
2020
import { createUserContent, FinishReason } from '@google/genai';
21-
import { retryWithBackoff, isRetryableError } from '../utils/retry.js';
21+
import {
22+
retryWithBackoff,
23+
isRetryableError,
24+
DEFAULT_MAX_ATTEMPTS,
25+
} from '../utils/retry.js';
2226
import type { ValidationRequiredError } from '../utils/googleQuotaErrors.js';
2327
import type { Config } from '../config/config.js';
2428
import {
@@ -621,7 +625,7 @@ export class GeminiChat {
621625
onRetry: (attempt, error, delayMs) => {
622626
coreEvents.emitRetryAttempt({
623627
attempt,
624-
maxAttempts: availabilityMaxAttempts ?? 10,
628+
maxAttempts: availabilityMaxAttempts ?? DEFAULT_MAX_ATTEMPTS,
625629
delayMs,
626630
error: error instanceof Error ? error.message : String(error),
627631
model: lastModelToUse,

packages/core/src/utils/retry.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { getErrorStatus, ModelNotFoundError } from './httpErrors.js';
1818
import type { RetryAvailabilityContext } from '../availability/modelPolicy.js';
1919

2020
export type { RetryAvailabilityContext };
21+
export const DEFAULT_MAX_ATTEMPTS = 3;
2122

2223
export interface RetryOptions {
2324
maxAttempts: number;
@@ -40,7 +41,7 @@ export interface RetryOptions {
4041
}
4142

4243
const DEFAULT_RETRY_OPTIONS: RetryOptions = {
43-
maxAttempts: 3,
44+
maxAttempts: DEFAULT_MAX_ATTEMPTS,
4445
initialDelayMs: 5000,
4546
maxDelayMs: 30000, // 30 seconds
4647
shouldRetryOnError: isRetryableError,

0 commit comments

Comments
 (0)