Skip to content

RetryConfig

Defined in: core/retry.ts:23

Configuration options for retry behavior.

// Custom retry with monitoring
const agent = LLMist.createAgent()
.withRetry({
retries: 5,
minTimeout: 2000,
onRetry: (error, attempt) => console.log(`Retry ${attempt}`),
})
.ask("Hello");

optional enabled: boolean

Defined in: core/retry.ts:28

Whether retry is enabled.

true

optional factor: number

Defined in: core/retry.ts:52

Exponential factor for backoff calculation.

2

optional maxTimeout: number

Defined in: core/retry.ts:46

Maximum delay between retries in milliseconds.

30000

optional minTimeout: number

Defined in: core/retry.ts:40

Minimum delay before the first retry in milliseconds.

1000

optional onRetriesExhausted: (error, attempts) => void

Defined in: core/retry.ts:70

Called when all retries are exhausted and the operation fails. The error will still be thrown after this callback.

Error

number

void


optional onRetry: (error, attempt) => void

Defined in: core/retry.ts:64

Called before each retry attempt. Use for logging or metrics.

Error

number

void


optional randomize: boolean

Defined in: core/retry.ts:58

Whether to add random jitter to prevent thundering herd.

true

optional retries: number

Defined in: core/retry.ts:34

Maximum number of retry attempts.

3

optional shouldRetry: (error) => boolean

Defined in: core/retry.ts:78

Custom function to determine if an error should trigger a retry. If not provided, uses the default isRetryableError classification.

Error

boolean

true to retry, false to fail immediately