SessionRunner<State> class
Executor responsible for running turns over input streams and persisting state.
The State type parameter mirrors the wrapped Session's: getCustom /
updateCustom delegate straight through, so a SessionRunner<State> exposes
the same typed custom-state API. It defaults to dynamic for the untyped
(raw-JSON) case.
- Annotations
-
- @experimental
Constructors
-
SessionRunner(Session<
State> session, Stream<AgentInput> inputCh, {SessionSnapshot? lastSnapshot, SessionStore? store, Map<String, dynamic> ? context, CancellationToken? cancel, OnEndTurn? onEndTurn, OnDetach? onDetach})
Properties
- cancel → CancellationToken?
-
Cooperative cancellation token (the Dart stand-in for
AbortSignal). When cancelled, a turn that rejects out ofgenerateis reported asaborted(notfailed) and settled with a singleabortedsnapshot write (the detached abort flip left the rowaborting, which this finalize settles).final -
context
→ Map<
String, dynamic> ? -
Ambient action context used to scope all persistent-store operations.
final
- firstCustomPatchInTurn ↔ bool
-
True until the first
customPatchchunk of the current turn has been emitted. The first patch of every turn is a whole-document replace.getter/setter pair - hashCode → int
-
The hash code for this object.
no setterinherited
-
inputCh
→ Stream<
AgentInput> -
final
- isDetached ↔ bool
-
getter/setter pair
- lastGoodState ↔ SessionState?
-
The state the most recently successful turn left behind. On a failed turn
this is the state the failed turn started with.
getter/setter pair
- lastGoodStateVersion ↔ int?
-
getter/setter pair
- lastSnapshot → SessionSnapshot?
-
The latest persisted snapshot (read-only view for callers).
no setter
- lastTurnError ↔ AgentErrorDetails?
-
Error details of the most recent failed turn.
getter/setter pair
- lastTurnFinishReason ↔ AgentFinishReason?
-
The finish reason of the most recently completed turn.
getter/setter pair
- newSnapshotId ↔ String?
-
getter/setter pair
- onDetach ↔ OnDetach?
-
getter/setter pair
- onEndTurn ↔ OnEndTurn?
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
session
→ Session<
State> -
final
- turnIndex ↔ int
-
getter/setter pair
Methods
-
addArtifacts(
List< Artifact> artifacts) → void - Adds artifacts to the session, deduplicating by name.
-
addMessages(
List< Message> messages) → void - Appends messages to the session.
-
ensureRecoverySnapshot(
) → Future< String?> - Returns the snapshotId a failed invocation should report as its resume point.
-
getArtifacts(
) → List< Artifact> - Retrieves the list of artifacts generated during the session.
-
getCustom(
) → State? -
Retrieves the custom state of the session as a typed
State. -
getMessages(
) → List< Message> - Retrieves all messages associated with the session.
-
getState(
) → SessionState - Returns a deep copy of the current session state.
-
maybeSnapshot(
{String? status, AgentErrorDetails? error, String? snapshotId, AgentFinishReason? finishReason}) → Future< String?> - Evaluates whether to save a snapshot to the persistent store.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
run(
Future< TurnResult?> fn(AgentInput input, TurnContext ctx)) → Future<void> - Executes the flow handler against incoming input messages sequentially.
-
setMessages(
List< Message> messages) → void - Overwrites the session messages.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateCustom(
State? fn(State? custom)) → void - Updates the custom state using a mutator function.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited