org.llm4s.agent.graph
Members list
Type members
Classlikes
One durable point in a thread's execution - data only. Closures, codecs and update functions are rebound from the compiled graph on restore; every value inside carries the version of the codec that wrote it (VersionedJson).
One durable point in a thread's execution - data only. Closures, codecs and update functions are rebound from the compiled graph on restore; every value inside carries the version of the codec that wrote it (VersionedJson).
parent is the checkpoint this one supersedes. A checkpointer accepts a new checkpoint only if parent is the thread's latest, so two writers cannot both advance one thread.
Persist with Checkpoint.toJson and read with Checkpoint.fromJson, which migrates older formatVersions and refuses newer ones.
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
Checkpoint.type
Whether a thread's latest checkpoint is mid-execution or finished its run.
Whether a thread's latest checkpoint is mid-execution or finished its run.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Durable storage for graph threads: each thread's latest checkpoint, the pending writes recorded against it, and its durable event log. One store owns all three so that a commit is atomic.
Durable storage for graph threads: each thread's latest checkpoint, the pending writes recorded against it, and its durable event log. One store owns all three so that a commit is atomic.
Implementations must be safe to call from several threads, and must:
- apply a Commit entirely or not at all;
- accept a new checkpoint only when its
parentis the thread's latest checkpoint id (GraphError.CheckpointConflict otherwise), and only pending writes naming the resulting latest checkpoint (GraphError.InvalidCommit); - number a thread's events
1, 2, 3, ...in commit order, inside the commit, never reusing a number - including after compaction or a failed commit; - keep events until compactEvents removes them, and report the earliest sequence still available when asked to replay from before it (GraphError.ReplayUnavailable).
Fencing a commit with a run-claim token is Stage 2; the parent check is its precursor.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class InMemoryCheckpointer
A node's state update and routes. Static edges declared on the builder are additive: they are scheduled before the command's routes. A command with no routes and no outgoing edges ends that branch; the run completes when no branch has work left.
A node's state update and routes. Static edges declared on the builder are additive: they are scheduled before the command's routes. A command with no routes and no outgoing edges ends that branch; the run completes when no branch has work left.
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
One atomic write to a thread. The checkpointer applies all of it or none of it:
One atomic write to a thread. The checkpointer applies all of it or none of it:
checkpoint, if present, becomes the thread's latest, provided itsparentis the current latest; pending writes recorded against the old checkpoint are dropped.pendingWritesare recorded against the (resulting) latest checkpoint, and must name it.eventsare appended to the thread's durable log, each given the next sequence number.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
An immutable, validated graph, run in supersteps.
An immutable, validated graph, run in supersteps.
Each superstep runs every ready task against the same committed ThreadState, then commits their updates and schedules the next frontier together:
- Tasks run in frontier order (possibly concurrently); none sees another's writes.
- If any task fails, the superstep commits nothing and the run fails with the first failure in frontier order.
- Each command is checked: every update is to a key in the node's declared write set, every route targets a node and join of this graph, and a task fans out to a join at most once.
- Updates apply task by task in frontier order, and in emission order within a task.
- The next frontier is, for each task in order, its static edges (declaration order) then its routes (route order, fan-out payloads in item order); then the targets of joins this commit released - static joins in declaration order, then dynamic activations in the order they opened.
The run completes when the frontier is empty and no join is waiting; a join still waiting at that point can never release and fails the run with GraphError.UnsatisfiedJoin.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
When a run's checkpoints and events become durable. In every mode a durable event is delivered only after the commit that numbered it, so no subscriber sees a sequence number that a crash could later reuse. Suspensions (#1269) will be persisted synchronously in every mode before a suspended result is returned.
When a run's checkpoints and events become durable. In every mode a durable event is delivered only after the commit that numbered it, so no subscriber sees a sequence number that a crash could later reuse. Suspensions (#1269) will be persisted synchronously in every mode before a suspended result is returned.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A barrier attached to a fan-out. A Route.FanOut opens an activation recording the task id of every child it schedules; target is scheduled once all of them have completed. An empty fan-out releases immediately.
A barrier attached to a fan-out. A Route.FanOut opens an activation recording the task id of every child it schedules; target is scheduled once all of them have completed. An empty fan-out releases immediately.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
A state operation as data: updates are encoded with the key's update codec.
A state operation as data: updates are encoded with the key's update codec.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A route as data: payloads are encoded with the target node's input codec.
A route as data: payloads are encoded with the target node's input codec.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A durable event before its commit assigns it a sequence number.
A durable event before its commit assigns it a sequence number.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A committed durable event. seq is per thread, allocated in the commit that stored the event, contiguous and never reused; an event is delivered to subscribers only after that commit.
A committed durable event. seq is per thread, allocated in the commit that stored the event, contiguous and never reused; an event is delivered to subscribers only after that commit.
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
EventRecord.type
A graph run paused at a superstep boundary: the committed state, the ready frontier and the open join activations. Advance it with CompiledGraph.step; persist it with CompiledGraph.snapshot.
A graph run paused at a superstep boundary: the committed state, the ready frontier and the open join activations. Advance it with CompiledGraph.step; persist it with CompiledGraph.snapshot.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Builds a typed graph. The builder issues every handle - nodes, joins - and validates the whole graph in compile, reporting every problem at once.
Builds a typed graph. The builder issues every handle - nodes, joins - and validates the whole graph in compile, reporting every problem at once.
Nodes that route to each other in a cycle are declared first and implemented afterwards:
val b = GraphBuilder("counter", "v1")
val count = StateKey.replace[Int]("count", 0)
val tick = b.declare[Unit]("tick")
b.implement(tick, writes = Set(count)) { (_, state, _) =>
NodeResult.fromResult(state.get(count).map { n =>
val next = Command.empty.update(count, n + 1)
if n + 1 < 3 then next.goto(tick) else next
})
}
val graph = b.compile(tick)(_.get(count))
The builder is mutable and meant to be used from one thread while the graph is assembled; the CompiledGraph it produces is immutable.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
GraphBuilder.type
Errors raised while building, running or restoring a typed graph.
Errors raised while building, running or restoring a typed graph.
Attributes
- Companion
- object
- Supertypes
-
trait NonRecoverableErrortrait LLMErrortrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
class CheckpointConflictclass CheckpointWriteFailedclass ForeignExecutionclass IncompleteRunclass InvalidCommitclass InvalidGraphclass InvalidRouteclass NodeFailedclass NothingToRecoverclass ReplayUnavailableclass RestoreRejectedclass StateUpdateFailedclass SuperstepLimitExceededclass UndeclaredWriteclass UnknownStateKeyclass UnsatisfiedJoinShow all
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
GraphError.type
A node's behaviour. It reads the superstep's committed snapshot - never another task's uncommitted writes - and returns its effects as data.
A node's behaviour. It reads the superstep's committed snapshot - never another task's uncommitted writes - and returns its effects as data.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Runs compiled graphs on durable threads.
Runs compiled graphs on durable threads.
start begins a run: on a new thread from the graph's entry, on a thread whose latest run completed by applying the input to its committed state. It refuses a thread with an incomplete execution (GraphError.IncompleteRun). recover continues an incomplete execution from its latest checkpoint without new input: tasks with a pending write are not run again, and failed or unstarted tasks run once more (per-node retry policy is Stage 1).
subscribe replays a thread's committed events after a sequence number and then delivers new ones as their commits succeed, in ascending order with no gaps or duplicates, followed by live progress as it happens. Events are delivered on the committing thread; a dedicated ordered dispatcher with bounded queues is part of the run API (#1271).
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
A serializable picture of an Execution - data only, no closures or codecs. Node inputs and state values are encoded with the codecs of the graph that wrote them, and decoded and checked against the graph that restores them.
A serializable picture of an Execution - data only, no closures or codecs. Node inputs and state values are encoded with the codecs of the graph that wrote them, and decoded and checked against the graph that restores them.
Each value records its codec's version and is migrated on restore; the snapshot itself is versioned by the Checkpoint that carries it.
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
GraphSnapshot.type
A Checkpointer in memory. Checkpoints and pending writes are stored as JSON and decoded on read, exactly as a database-backed store would, so nothing executable survives a round trip.
A Checkpointer in memory. Checkpoints and pending writes are stored as JSON and decoded on read, exactly as a database-backed store would, so nothing executable survives a round trip.
Attributes
- Supertypes
The running task's identity, for attribution and idempotency keys, and its event channels.
The running task's identity, for attribution and idempotency keys, and its event channels.
emit records a durable custom event: it is committed with this task's result, given a per-thread sequence number in that commit, delivered only after the commit and replayed to later subscribers. It is discarded if the task fails. progress is live-only, for token deltas and similar high-volume progress: delivered at once to current subscribers, never persisted or replayed. Outside a GraphRuntime both are no-ops.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
A handle to a node that consumes I, issued by a GraphBuilder.
A handle to a node that consumes I, issued by a GraphBuilder.
Handles are the only way to route: a node cannot name another by string. Goto takes a NodeRef[Unit] and Send a payload of the target's input type, so a mis-typed route does not compile. A handle from another builder is rejected when the graph compiles, or when a node returns it at run time.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
What a node task produced.
What a node task produced.
Attributes
- Companion
- object
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- enum
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
NodeResult.type
A completed task's result, recorded against the checkpoint whose frontier it ran in, before the superstep commits. On recovery the task is not run again: its command is decoded from here.
A completed task's result, recorded against the checkpoint whose frontier it ran in, before the superstep commits. On recovery the task is not run again: its command is decoded from here.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A routing decision returned by a node; scheduled for the next superstep.
What happened in a run. Durable: persisted in the thread's event log and replayable.
What happened in a run. Durable: persisted in the thread's event log and replayable.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The current version of a persisted JSON shape, with the migrations that bring older versions up to it. A state key's value, a state key's update and a node's input each carry one; their stable codec id is the owner's id with this version (<keyId>@<version>), and every encoded value records the version it was written with (see VersionedJson).
The current version of a persisted JSON shape, with the migrations that bring older versions up to it. A state key's value, a state key's update and a node's input each carry one; their stable codec id is the owner's id with this version (<keyId>@<version>), and every encoded value records the version it was written with (see VersionedJson).
A step keyed n migrates JSON written at version n to version n + 1. Steps are plain functions of the compiled graph, never persisted.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
SchemaVersion.type
A typed slot in a graph's thread state.
A typed slot in a graph's thread state.
A is the stored value and U the update a node emits for it. Every update - including a single writer's - is applied to the committed value with applyUpdate, in deterministic task and emission order; replacement is the special case U = A (see StateKey.replace). The function belongs to the compiled graph, never to a checkpoint: checkpoints hold values encoded with stateCodec and pending updates encoded with updateCodec, each tagged with the codec's SchemaVersion so an older checkpoint is migrated before it is decoded.
Keys are compared by identity. A graph rejects two distinct keys with the same id.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
StateKeyId.type
An ordered list of state operations emitted by one node task.
An ordered list of state operations emitted by one node task.
Operations apply in emission order. combine is sequential composition: a.combine(b) applies a's operations and then b's, so for a StateKey.replace key the later value wins and for an operation-valued key both operations apply. Updates from different tasks in one superstep are never combined; the scheduler applies them task by task in frontier order.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
StateUpdate.type
A barrier that schedules target once every source node has completed a task since its last release. Each source counts once per activation, however many of its tasks complete.
A barrier that schedules target once every source node has completed a task since its last release. Each source counts once per activation, however many of its tasks complete.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
A thread's latest checkpoint with the pending writes recorded against it.
A thread's latest checkpoint with the pending writes recorded against it.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
What a subscriber receives.
What a subscriber receives.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A registration with GraphRuntime.subscribe.
A registration with GraphRuntime.subscribe.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ThreadId.type
The committed state of a graph thread: a typed key/value store over the graph's registered StateKeys. It is immutable, so every task in a superstep reads the same snapshot.
The committed state of a graph thread: a typed key/value store over the graph's registered StateKeys. It is immutable, so every task in a superstep reads the same snapshot.
Reads are checked: a key the graph did not register - or a different key instance sharing a registered key's id - is an GraphError.UnknownStateKey. A registered key with no stored entry reads as its initial value. The erasure to Any stays private to this boundary.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
A persisted value and the version of the codec that wrote it.
A persisted value and the version of the codec that wrote it.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Types
Stable identifier of a static or dynamic join barrier; persisted in snapshots.
Stable identifier of a static or dynamic join barrier; persisted in snapshots.
Attributes
Stable identifier of a node in a compiled graph; persisted in snapshots.
Stable identifier of a node in a compiled graph; persisted in snapshots.
Attributes
One execution attempt on a thread; start, recover and (later) resume each begin a new run.
One execution attempt on a thread; start, recover and (later) resume each begin a new run.
Attributes
Identifier of one scheduled node execution; unique within a thread's history.
Identifier of one scheduled node execution; unique within a thread's history.
Attributes
A conversation or workflow thread: the address of its checkpoints and event log.
A conversation or workflow thread: the address of its checkpoints and event log.