Optionaloptions: {True until the first customPatch chunk of the current turn has been
emitted. The first patch of every turn is a whole-document replace
(re-basing clients that may not share the server's baseline); reset to
true at the start of each turn.
ReadonlyinputOptionallastThe snapshotId of the most recently successful (persisted, done) turn.
On a failed turn this is the last-good snapshot the caller resumes from;
undefined when no turn has succeeded yet (e.g. a first-turn failure).
OptionallastThe state the most recently successful turn left behind. On a failed turn this is the state the failed turn started with - the last-good state returned to the caller (for client-managed agents).
OptionallastError details of the most recent failed turn. Set when a turn throws and the runner resolves gracefully instead of propagating the exception.
OptionallastThe finish reason of the most recently completed turn.
OptionalnewOptionalonOptionalonReadonlysessionAdds artifacts to the session, deduplicating by name.
Appends messages to the session.
Retrieves the list of artifacts generated during the session.
Retrieves the custom state of the session.
Retrieves all messages associated with the session.
Returns a deep copy of the current session state.
Saves a snapshot of the current session state to the persistent store.
When a store is configured every turn is persisted (snapshotting is no
longer opt-out). Uses the mutator-based saveSnapshot to atomically check
that the snapshot has not been concurrently aborted before writing -
preventing a race where a "done" write could overwrite a concurrent
"aborted" status.
Optionalstatus: "failed" | "completed" | "pending"Optionalerror: { details?: any; message: string; status?: string }OptionalsnapshotId: stringOptionalfinishReason: Executes the flow handler against incoming input messages sequentially.
The handler receives the turn's AgentInput and a TurnContext
whose snapshotId is reserved up front - it is the id the snapshot
persisted at turn end will reuse. This lets a handler set up external,
snapshot-correlated state (e.g. a git branch/worktree named after the
snapshot) before generating, then commit it under that id.
The handler may return a TurnResult carrying an explicit
finishReason for the just-completed turn. When omitted, no per-turn
reason is reported. Failures always report failed.
Overwrites the session messages.
Executor responsible for running turns over input streams and persisting state.