Skip to main content

Module retry

Module retry 

Source
Expand description

Reliability decorator: RetryingModel wraps any CompletionModel and retries setup-time failures with exponential backoff that honours Retry-After hints surfaced by the adapter.

Each adapter classifies its own error type via the Retryable trait (AnthropicError in ailoop-anthropic, AzureOpenAIError in ailoop-azure-openai); the decorator only needs to know whether an error is Permanent or Transient { retry_after }.

§Scope

Only the call to CompletionModel::chat_stream is retried. Once the stream is open, mid-stream errors propagate to the caller unchanged — the engine has already consumed deltas and built partial assistant state, and replaying from that point is not safe in general. Reissuing the entire request from the engine layer would also discard work the model has already done. If retry-on-mid-stream becomes important later it belongs above this layer (in the engine), not here.

Structs§

RetryConfig
Backoff settings for RetryingModel.
RetryingModel
Decorator that retries setup-time failures of an inner CompletionModel using exponential backoff with optional jitter, honouring Retry-After when the inner error provides it.

Enums§

RetryClassification
Outcome of Retryable::retry_classification: whether the decorator should attempt the call again, and after how long.

Traits§

Retryable
Adapter-side classification of an error as retryable or not.