ToolRetryPolicy

org.llm4s.toolapi.ToolRetryPolicy
See theToolRetryPolicy companion object
@Stable
final case class ToolRetryPolicy

Simple retry policy with exponential backoff and optional jitter.

Build one with ToolRetryPolicy.apply and change it with the with* setters.

Value parameters

backoffFactor

Multiplier for each subsequent delay (e.g. 2.0 => baseDelay, 2baseDelay, 4baseDelay).

baseDelay

Delay after first failure before first retry.

jitter

Fraction of each delay, from 0.0 to 1.0, that is randomised so that many callers retrying on the same schedule do not hit the backend together. The wait before a retry is drawn uniformly between (1 - jitter) * d and d, where d is delayBeforeAttempt: 0.0 (the default) waits exactly d, 0.5 is "equal jitter" and 1.0 is "full jitter" (anywhere from zero to d). The wait is never longer than d.

maxAttempts

Total attempts (first try + retries); must be >= 1.

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 delayBeforeAttempt(attempt: Int): FiniteDuration

Delay before the given retry attempt (1-based: 1 is the first retry, after the initial try). attempt 1 -> baseDelay, attempt 2 -> baseDelay * backoffFactor, etc. With jitter set, this is the longest the wait can be.

Delay before the given retry attempt (1-based: 1 is the first retry, after the initial try). attempt 1 -> baseDelay, attempt 2 -> baseDelay * backoffFactor, etc. With jitter set, this is the longest the wait can be.

Attributes

def withBackoffFactor(backoffFactor: Double): ToolRetryPolicy

Sets the multiplier for each subsequent delay; must be >= 1.0.

Sets the multiplier for each subsequent delay; must be >= 1.0.

Attributes

def withBaseDelay(baseDelay: FiniteDuration): ToolRetryPolicy

Sets the delay after the first failure, before the first retry.

Sets the delay after the first failure, before the first retry.

Attributes

def withJitter(jitter: Double): ToolRetryPolicy

Sets the fraction of each delay that is randomised, from 0.0 (none) to 1.0 ("full jitter"); see the class comment.

Sets the fraction of each delay that is randomised, from 0.0 (none) to 1.0 ("full jitter"); see the class comment.

Attributes

def withMaxAttempts(maxAttempts: Int): ToolRetryPolicy

Sets the total number of attempts (first try + retries); must be >= 1.

Sets the total number of attempts (first try + retries); must be >= 1.

Attributes

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product