Alloy.Provider.Retry (alloy v0.10.1)

Copy Markdown View Source

Provider retry, backoff, fallback, and streaming dispatch logic.

Handles exponential backoff with full jitter, retryable error classification, fallback provider chains, and receive-timeout injection. Extracted from Alloy.Agent.Turn to separate provider-oriented concerns from agent loop control flow.

Summary

Functions

Call a provider with retry, backoff, and fallback logic.

Functions

call_with_retry(state, provider, provider_config, streaming?, on_chunk, deadline)

@spec call_with_retry(
  Alloy.Agent.State.t(),
  module(),
  map(),
  boolean(),
  function(),
  integer()
) ::
  {:ok, map()} | {:error, term()}

Call a provider with retry, backoff, and fallback logic.

Single entry point for all provider calls. Retries on transient errors with exponential backoff and jitter, then falls back to configured fallback providers if the primary provider fails.

Returns {:ok, response} or {:error, reason}.