RetryPolicy

org.llm4s.agent.graph.RetryPolicy
See theRetryPolicy companion object
final case class RetryPolicy

How a node is run again after its own failure, inside the run.

A node that throws, or returns NodeResult.Fail, is run again against the same committed snapshot while its error passes retryOn and attempts remain. By default an error is retried by the library's one retry rule, org.llm4s.reliability.RetryPolicy.isRetryable: a recoverable error, except a client-error response and an optimistic-lock failure, which repeating the node cannot fix. A cancellation, a result the kernel rejects (an undeclared write, an invalid route) and a suspension are never retried.

The wait after the n-th failed attempt is initialBackoff * backoffFactor^(n-1), at most maxBackoff. It is an interruptible wait: cancelling the run, or its deadline expiring, ends the retries. The attempts belong to one run: recover runs a failed task again with its full policy.

Every value is validated on the way in: apply and the with* setters throw IllegalArgumentException; RetryPolicy.of returns a ValidationError for untrusted input.

Value parameters

backoffFactor

what each further wait is multiplied by; at least 1.0

initialBackoff

the wait after the first failed attempt

maxAttempts

the most times the node is run, the first included; 1 means no retry

maxBackoff

the longest wait

retryOn

whether an error is worth another attempt

Attributes

Companion
object
Source
RetryPolicy.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def backoffAfter(failedAttempts: Int): FiniteDuration

The wait after failedAttempts attempts have failed: failedAttempts = 1 after the first.

The wait after failedAttempts attempts have failed: failedAttempts = 1 after the first.

Attributes

Source
RetryPolicy.scala

Attributes

Source
RetryPolicy.scala
def withRetryOn(predicate: LLMError => Boolean): RetryPolicy

Attributes

Source
RetryPolicy.scala

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product