Retry wrapper for LLM calls with exponential backoff and jitter.
Retries on transient errors (HTTP 429, 500, 502, 503, 504, connection errors). Does NOT retry on client errors (400, 401, 403, 404).
Options
:max_retries- Maximum number of retry attempts (default: 3):base_delay_ms- Base delay in milliseconds (default: 1000):max_delay_ms- Maximum delay in milliseconds (default: 30_000)
Examples
ADK.LLM.Retry.with_retry(fn -> ADK.LLM.Gemini.generate(model, request) end)
ADK.LLM.Retry.with_retry(
fn -> ADK.LLM.Gemini.generate(model, request) end,
max_retries: 5, base_delay_ms: 500
)
Summary
Functions
Compute backoff delay with jitter for the given attempt.
Returns true if the error is transient and should be retried.
Execute fun with retry logic. Returns the first success or the last error.
Functions
@spec compute_delay(non_neg_integer(), pos_integer(), pos_integer()) :: non_neg_integer()
Compute backoff delay with jitter for the given attempt.
Returns true if the error is transient and should be retried.
@spec with_retry( (-> {:ok, term()} | {:error, term()}), keyword() ) :: {:ok, term()} | {:error, term()}
Execute fun with retry logic. Returns the first success or the last error.