Record Class LlmRetryPolicy

java.lang.Object
java.lang.Record
com.agentforge4j.llm.api.LlmRetryPolicy

public record LlmRetryPolicy(int maxAttempts, long baseBackoffMs, long maxBackoffMs, long maxElapsedMs) extends Record
Immutable retry settings for a retrying LLM client: attempt cap, decorrelated jitter bounds, and optional total elapsed budget.
  • Constructor Summary

    Constructors
    Constructor
    Description
    LlmRetryPolicy(int maxAttempts, long baseBackoffMs, long maxBackoffMs, long maxElapsedMs)
    Creates a retry policy with the given parameters, validating that they are within expected bounds.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the value of the baseBackoffMs record component.
    Default retry policy: 3 attempts, 200ms base backoff, 10s max backoff, 30s total elapsed budget.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the maxAttempts record component.
    long
    Returns the value of the maxBackoffMs record component.
    long
    Returns the value of the maxElapsedMs record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • LlmRetryPolicy

      public LlmRetryPolicy(int maxAttempts, long baseBackoffMs, long maxBackoffMs, long maxElapsedMs)
      Creates a retry policy with the given parameters, validating that they are within expected bounds.
      Parameters:
      maxAttempts - Max retry attempts (must be >= 1)
      baseBackoffMs - Base backoff in ms for decorrelated jitter (must be >= 0)
      maxBackoffMs - Max backoff in ms for decorrelated jitter (must be >= baseBackoffMs)
      maxElapsedMs - Optional total elapsed budget in ms for all attempts (must be >= 0)
  • Method Details

    • defaults

      public static LlmRetryPolicy defaults()
      Default retry policy: 3 attempts, 200ms base backoff, 10s max backoff, 30s total elapsed budget.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • maxAttempts

      public int maxAttempts()
      Returns the value of the maxAttempts record component.
      Returns:
      the value of the maxAttempts record component
    • baseBackoffMs

      public long baseBackoffMs()
      Returns the value of the baseBackoffMs record component.
      Returns:
      the value of the baseBackoffMs record component
    • maxBackoffMs

      public long maxBackoffMs()
      Returns the value of the maxBackoffMs record component.
      Returns:
      the value of the maxBackoffMs record component
    • maxElapsedMs

      public long maxElapsedMs()
      Returns the value of the maxElapsedMs record component.
      Returns:
      the value of the maxElapsedMs record component