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 only a recoverable error is retried (LLMError.isRecoverable). 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
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

def withBackoffFactor(f: Double): RetryPolicy
def withInitialBackoff(d: FiniteDuration): RetryPolicy
def withMaxBackoff(d: FiniteDuration): RetryPolicy
def withRetryOn(predicate: LLMError => Boolean): RetryPolicy

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product