ClaimPolicy

org.llm4s.agent.graph.ClaimPolicy
See theClaimPolicy companion object
@Experimental
final case class ClaimPolicy

How a GraphRuntime holds its runs' claims: each claim lasts ttl from when the store grants or renews it, and is renewed every renewEvery from its grant - also while the run is still being admitted, and while fork or updateState holds a thread - until it is released. A process that dies stops renewing, so after at most ttl its threads can be recovered elsewhere.

A run judges its own lease: it ends ttl after the moment, by the runtime's monotonic clock, just before the request that granted or last renewed the claim was sent. A run whose renewals fail or hang until that lease passes - its store is unreachable, or partitioned from it - stops at once, as one whose renewal or commit the store refuses as stale does: its tasks are interrupted, it commits nothing more, and it fails with GraphError.ClaimLost. A renewal that fails is tried again at the next beat while the lease lasts. Tasks already running when the loss is found may still complete a side effect before they see their interrupt.

A renewal must land within ttl - renewEvery of being due, or the run judges its lease passed and stops: keep renewEvery at most a third of ttl, as the default does, so a renewal can fail or be slow once and still be retried in time.

label, when set, names the runtime to an operator: it is logged with the run id when a claim is granted (at INFO; without a label, at DEBUG) and when a renewal fails or the claim is lost, so that the holder a GraphError.ThreadBusy names can be traced to the runtime holding it - a host, a pod, a process. It goes nowhere else: not to the store, and not into an error another caller gets.

Both durations must be positive and renewEvery shorter than ttl, and a label must not be blank: apply and the with* setters throw IllegalArgumentException otherwise, and ClaimPolicy.of returns a ValidationError.

Attributes

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

Members list

Value members

Concrete methods

Attributes

Source
RunClaim.scala

Attributes

Source
RunClaim.scala

Attributes

Source
RunClaim.scala

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product