RetrySchedule

org.llm4s.ox.RetrySchedule
@Experimental
object RetrySchedule

Ox retry presets for Result-returning llm4s calls.

What is retried is the library's one rule for automatic retry, the one ReliableClient and the agent graph use (org.llm4s.reliability.RetryPolicy's isRetryable): a recoverable error, except a ServiceError or an APIError with a client-error status (any 4xx but 408 and 429) and an OptimisticLockFailure. Every other error, a CancelledError included, is returned at once.

val answer: Result[Completion] = RetrySchedule.retry()(client.complete(conversation))
val custom = retryEither(RetrySchedule.config[Completion](Schedule.fixedInterval(2.seconds).maxRetries(5)))(
 client.complete(conversation)
)

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def config[A](schedule: Schedule): RetryConfig[LLMError, A]

An Ox RetryConfig on schedule with policy, for Ox's own retryEither. It waits the schedule's delays only; retry also honours the provider's retry-after hint.

An Ox RetryConfig on schedule with policy, for Ox's own retryEither. It waits the schedule's delays only; retry also honours the provider's retry-after hint.

Attributes

def policy[A]: ResultPolicy[LLMError, A]

Retries only what RetryPolicy.isRetryable retries; every result is a success.

Retries only what RetryPolicy.isRetryable retries; every result is a success.

Attributes

def retry[A](schedule: Schedule)(operation: => Result[A]): Result[A]

Runs operation, retrying it on schedule (by default default) while it fails with an error RetryPolicy.isRetryable retries, and returns its first success or its last failure.

Runs operation, retrying it on schedule (by default default) while it fails with an error RetryPolicy.isRetryable retries, and returns its first success or its last failure.

The wait before a retry is the schedule's delay, or longer when the provider asked for longer: a RateLimitError waits at least its retryDelay (its retry-after, else RateLimitError.DefaultRetryDelay), a ServiceError at least its explicit retryAfter, as core's ErrorRecovery does. Built on Ox's retryEither; an interrupt during a wait propagates as InterruptedException, so an enclosing scope can end.

Attributes

Concrete fields

val default: Schedule

Exponential backoff from 1 second, each delay capped at 30 seconds, with equal jitter: at most 3 retries.

Exponential backoff from 1 second, each delay capped at 30 seconds, with equal jitter: at most 3 retries.

Attributes