Polyman Documentation - v3.1.0
    Preparing search index...

    Interface RetryOptions

    How withRetries retries.

    interface RetryOptions {
        maxRetries?: number;
        baseDelayMs?: number;
        maxDelayMs?: number;
        jitter?: number;
        random?: () => number;
        onContextTooLong?: (
            req: ChatRequest,
            error: ProviderError,
            signal: AbortSignal,
        ) => ChatRequest | Promise<ChatRequest | undefined> | undefined;
        onRetry?: (info: RetryInfo) => void;
        secrets?: readonly string[];
    }
    Index
    maxRetries?: number

    Retries after the first try. Defaults to 3.

    baseDelayMs?: number

    First backoff delay, doubled on each retry. Defaults to 1000 ms.

    maxDelayMs?: number

    The longest we wait before one retry. Backoff is cut to it, and a retry-after longer than it is not waited: the error is thrown. Defaults to 60000 ms.

    jitter?: number

    Adds up to this part of the backoff delay at random. Defaults to 0.2.

    random?: () => number

    Random numbers in [0, 1) for the jitter. Defaults to Math.random.

    onContextTooLong?: (
        req: ChatRequest,
        error: ProviderError,
        signal: AbortSignal,
    ) => ChatRequest | Promise<ChatRequest | undefined> | undefined

    Called once per turn on context_too_long. It returns a smaller request to try once more, or undefined to give up.

    onRetry?: (info: RetryInfo) => void

    Called before each wait, so the user can see why nothing happens.

    secrets?: readonly string[]

    Strings that must never show in an error message, like the API key.