# Function withRetryWrapper

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

- withRetryWrapper<TArgs extends unknown[], TReturn>(
  fn: (...args: TArgs) => Promise<TReturn>,
  options?: WithRetryOptions,
  ): (...args: TArgs) => Promise<Result<TReturn, RetryExhaustedError>>

  Wraps an async function with retry logic.

  #### Type Parameters

  - TArgs extends unknown[]

    The argument types of the function

  - TReturn

    The return type of the function

  #### Parameters

  - fn: (...args: TArgs) => Promise<TReturn>

    The function to wrap

  - options: WithRetryOptions = {}

    Retry options

  #### Returns (...args: TArgs) => Promise<Result<TReturn, RetryExhaustedError>>

  A wrapped function that will retry on failure

  #### Example

      const fetchWithRetry = withRetryWrapper(
        async (url: string) => fetch(url),
        { config: { maxRetries: 3 } }
      );

      const result = await fetchWithRetry('https://api.example.com/data');

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