Retry policy for transient failures.
Defines how many times to retry and how long to wait between attempts.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Abstract methods
Calculate delay before next retry attempt.
Calculate delay before next retry attempt.
Value parameters
- attemptNumber
-
The attempt number (1-indexed)
- error
-
The error that triggered the retry
Attributes
- Returns
-
Delay duration before next attempt
Maximum number of retry attempts
Maximum number of retry attempts
Attributes
Concrete methods
Check if an error is retryable: whether the identical request is worth sending again, with nobody in the loop.
Check if an error is retryable: whether the identical request is worth sending again, with nobody in the loop.
This is the library's one rule for automatic retry, and LLMClientRetry and the agent graph's node retries use it too. It is derived from org.llm4s.error.LLMError.isRecoverable, never wider: an error is retried only if it is a org.llm4s.error.RecoverableError. isRecoverable says an error may succeed if tried again, perhaps after the caller does something first; this rule keeps the part where repeating the same request is enough. A recoverable error is therefore retried unless one of two documented exceptions applies:
- '''A client-error HTTP status.''' A org.llm4s.error.ServiceError or an org.llm4s.error.APIError that carries a status is retried only for 5xx, 429 or 408. Any other 4xx means the request itself is wrong, so sending it unchanged cannot succeed. An
APIErrorwith no status is retried: nothing says it cannot be. - '''An org.llm4s.error.OptimisticLockFailure.''' The caller must re-read the record first; the same update fails again until it does.
So the retried errors are org.llm4s.error.RateLimitError, org.llm4s.error.TimeoutError, org.llm4s.error.NetworkError, org.llm4s.error.ExecutionError, org.llm4s.error.SystemError, an APIError or ServiceError with a retryable status, and an APIError without one. Every org.llm4s.error.NonRecoverableError is not, including org.llm4s.error.CancelledError.