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)
)
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.
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.