# `LlmCore.Memory.Hindsight.Retry`
[🔗](https://github.com/fosferon/llm_core/blob/v0.3.0/lib/llm_core/memory/hindsight/retry.ex#L1)

Retry logic with exponential backoff for Hindsight operations.

Features:
- Configurable max retries and backoff timing
- Jitter to prevent thundering herd
- Retry classification (retry transient, fail fast on client errors)

## Retry Classification

- **Retry**: connection_refused, timeout, 5xx errors
- **No retry**: 4xx errors, invalid response

# `retry_result`

```elixir
@type retry_result() :: {:ok, term()} | {:error, term()}
```

# `get_delay`

```elixir
@spec get_delay(non_neg_integer(), [pos_integer()]) :: pos_integer()
```

Gets the delay for a specific retry attempt with jitter.

# `should_retry?`

```elixir
@spec should_retry?(term()) :: boolean()
```

Determines if an error should be retried.

# `with_retry`

```elixir
@spec with_retry(
  (-&gt; {:ok, term()} | {:error, term()}),
  keyword()
) :: retry_result()
```

Wraps an operation with retry logic.

## Options
- `:max_retries` - maximum retry attempts (default from config)
- `:backoff_ms` - list of backoff delays in ms (default from config)

## Example

    Retry.with_retry(fn -> do_request() end, max_retries: 3)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
