Skip to content

InMemoryWorkflowCheckpointStore

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Stores workflow checkpoints in process memory.

public sealed class InMemoryWorkflowCheckpointStore : IWorkflowCheckpointStore

objectInMemoryWorkflowCheckpointStore

IWorkflowCheckpointStore

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

In-memory checkpoints are limited to the process lifetime. This is a deliberate constraint: durable resumption requires UsePostgreSql, and hiding that would cause a “checkpoint disappeared” surprise after an application restart.

To prevent unbounded growth, InMemoryWorkflowCheckpointStore.MaxCheckpointsPerSession limits checkpoints held per session and discards the oldest one.

public InMemoryWorkflowCheckpointStore()

Gets the maximum checkpoints held in memory for a session.

public const int MaxCheckpointsPerSession = 50

int

CreateAsync(WorkflowCheckpointRecord, CancellationToken)

Section titled “ CreateAsync(WorkflowCheckpointRecord, CancellationToken)”

Writes a new checkpoint.

public ValueTask<WorkflowCheckpointRecord> CreateAsync(WorkflowCheckpointRecord record, CancellationToken cancellationToken = default)

record WorkflowCheckpointRecord

The record to write.

cancellationToken CancellationToken

The cancellation token.

ValueTask<WorkflowCheckpointRecord>

The written record.

DeleteAsync(string, string, CancellationToken)

Section titled “ DeleteAsync(string, string, CancellationToken)”

Deletes all of a session’s checkpoints.

public ValueTask<int> DeleteAsync(string tenantId, string sessionId, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

sessionId string

The execution session identifier.

cancellationToken CancellationToken

The cancellation token.

ValueTask<int>

The number of records deleted.

ListAsync(string, string, CancellationToken)

Section titled “ ListAsync(string, string, CancellationToken)”

Lists a session’s checkpoints, oldest to newest. The state payload is not read; only metadata is returned.

public ValueTask<IReadOnlyList<WorkflowCheckpointRecord>> ListAsync(string tenantId, string sessionId, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

sessionId string

The execution session identifier.

cancellationToken CancellationToken

The cancellation token.

ValueTask<IReadOnlyList<WorkflowCheckpointRecord>>

The records.

ListByRunAsync(string, Guid, CancellationToken)

Section titled “ ListByRunAsync(string, Guid, CancellationToken)”

Lists the checkpoints a single run produced, oldest to newest. The state payload is not read.

public ValueTask<IReadOnlyList<WorkflowCheckpointRecord>> ListByRunAsync(string tenantId, Guid runId, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

runId Guid

The run identifier.

cancellationToken CancellationToken

The cancellation token.

ValueTask<IReadOnlyList<WorkflowCheckpointRecord>>

The records.

Separate from the session-based list: a session can carry multiple runs (resuming opens a new run each time), and the UI asks “where can this run be resumed from.”

ReadAsync(string, string, string, CancellationToken)

Section titled “ ReadAsync(string, string, string, CancellationToken)”

Reads a single checkpoint’s state.

public ValueTask<JsonElement?> ReadAsync(string tenantId, string sessionId, string checkpointId, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

sessionId string

The execution session identifier.

checkpointId string

The checkpoint identifier.

cancellationToken CancellationToken

The cancellation token.

ValueTask<JsonElement?>

The opaque state; null if the record does not exist or belongs to another tenant.