# Function withRetry

Adapters exports - Model adapters (Claude, OpenAI, Gemini, Ollama) Split from index.ts for file size compliance (Issue #285)

- withRetry<T>(
  operation: () => Promise<T>,
  options?: WithRetryOptions,
  ): Promise<Result<T, RetryExhaustedError>>

  Executes an operation with retry logic using exponential backoff.

  #### Type Parameters

  - T

    The return type of the operation

  #### Parameters

  - operation: () => Promise<T>

    The async operation to execute

  - options: WithRetryOptions = {}

    Retry options (config, isRetryable predicate, onRetry callback)

  #### Returns Promise<Result<T, RetryExhaustedError>>

  A Result containing either the operation result or a RetryExhaustedError

  #### Example

      const result = await withRetry(
        () => fetchData('/api/data'),
        { config: { maxRetries: 5 } }
      );

      if (result.ok) {
        console.log(result.value);
      } else {
        console.error('All retries failed:', result.error);
      }

  - Defined in packages/nexus-agents/src/adapters/retry.ts:319