mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-12 23:21:27 -07:00
Set default max attempts to 3 and use the common variable (#18209)
This commit is contained in:
@@ -18,7 +18,11 @@ import type {
|
|||||||
} from '@google/genai';
|
} from '@google/genai';
|
||||||
import { toParts } from '../code_assist/converter.js';
|
import { toParts } from '../code_assist/converter.js';
|
||||||
import { createUserContent, FinishReason } from '@google/genai';
|
import { createUserContent, FinishReason } from '@google/genai';
|
||||||
import { retryWithBackoff, isRetryableError } from '../utils/retry.js';
|
import {
|
||||||
|
retryWithBackoff,
|
||||||
|
isRetryableError,
|
||||||
|
DEFAULT_MAX_ATTEMPTS,
|
||||||
|
} from '../utils/retry.js';
|
||||||
import type { ValidationRequiredError } from '../utils/googleQuotaErrors.js';
|
import type { ValidationRequiredError } from '../utils/googleQuotaErrors.js';
|
||||||
import type { Config } from '../config/config.js';
|
import type { Config } from '../config/config.js';
|
||||||
import {
|
import {
|
||||||
@@ -621,7 +625,7 @@ export class GeminiChat {
|
|||||||
onRetry: (attempt, error, delayMs) => {
|
onRetry: (attempt, error, delayMs) => {
|
||||||
coreEvents.emitRetryAttempt({
|
coreEvents.emitRetryAttempt({
|
||||||
attempt,
|
attempt,
|
||||||
maxAttempts: availabilityMaxAttempts ?? 10,
|
maxAttempts: availabilityMaxAttempts ?? DEFAULT_MAX_ATTEMPTS,
|
||||||
delayMs,
|
delayMs,
|
||||||
error: error instanceof Error ? error.message : String(error),
|
error: error instanceof Error ? error.message : String(error),
|
||||||
model: lastModelToUse,
|
model: lastModelToUse,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { getErrorStatus, ModelNotFoundError } from './httpErrors.js';
|
|||||||
import type { RetryAvailabilityContext } from '../availability/modelPolicy.js';
|
import type { RetryAvailabilityContext } from '../availability/modelPolicy.js';
|
||||||
|
|
||||||
export type { RetryAvailabilityContext };
|
export type { RetryAvailabilityContext };
|
||||||
|
export const DEFAULT_MAX_ATTEMPTS = 3;
|
||||||
|
|
||||||
export interface RetryOptions {
|
export interface RetryOptions {
|
||||||
maxAttempts: number;
|
maxAttempts: number;
|
||||||
@@ -40,7 +41,7 @@ export interface RetryOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_RETRY_OPTIONS: RetryOptions = {
|
const DEFAULT_RETRY_OPTIONS: RetryOptions = {
|
||||||
maxAttempts: 3,
|
maxAttempts: DEFAULT_MAX_ATTEMPTS,
|
||||||
initialDelayMs: 5000,
|
initialDelayMs: 5000,
|
||||||
maxDelayMs: 30000, // 30 seconds
|
maxDelayMs: 30000, // 30 seconds
|
||||||
shouldRetryOnError: isRetryableError,
|
shouldRetryOnError: isRetryableError,
|
||||||
|
|||||||
Reference in New Issue
Block a user