Persistency

class Persistency(persistencyStorageProvider: PersistencyStorageProvider)(source)

A feature that provides checkpoint functionality for AI agents.

This class allows saving and restoring the state of an agent at specific points during execution. Checkpoints capture the agent's message history, current node, and input data, enabling:

  • Resuming agent execution from a specific point

  • Rolling back to previous states

  • Persisting agent state across sessions

The feature can be configured to automatically create checkpoints after each node execution using the PersistencyFeatureConfig.enableAutomaticPersistency option.

Constructors

Link copied to clipboard
constructor(persistencyStorageProvider: PersistencyStorageProvider)

Types

Link copied to clipboard

Feature companion object that implements AIAgentFeature for the checkpoint functionality.

Properties

Link copied to clipboard

Represents the identifier of the current node being executed within the agent pipeline.

Functions

Link copied to clipboard
suspend fun createCheckpoint(agentContext: AIAgentContextBase, nodeId: String, lastInput: Any?, lastInputType: KType, checkpointId: String? = null): AgentCheckpointData?

Creates a checkpoint of the agent's current state.

Link copied to clipboard
suspend fun getCheckpointById(checkpointId: String): AgentCheckpointData?

Retrieves a specific checkpoint by ID for the specified agent.

Link copied to clipboard

Retrieves the latest checkpoint for the specified agent.

Link copied to clipboard
suspend fun rollbackToCheckpoint(checkpointId: String, agentContext: AIAgentContextBase): AgentCheckpointData?

Rolls back an agent's state to a specific checkpoint.

Link copied to clipboard

Rolls back an agent's state to the latest checkpoint.

Link copied to clipboard
suspend fun saveCheckpoint(checkpointData: AgentCheckpointData)

Saves a checkpoint using the configured storage provider.

Link copied to clipboard
fun setExecutionPoint(agentContext: AIAgentContextBase, nodeId: String, messageHistory: List<Message>, input: JsonElement)

Sets the execution point of an agent to a specific state.