Class WorkflowExecutionState
Tracks workflow execution state with checkpoint support for resume-from-failure. Each execution run stores per-step completion status and intermediate results, enabling workflows to resume from the last successful checkpoint.
public sealed class WorkflowExecutionState
- Inheritance
-
WorkflowExecutionState
- Inherited Members
Constructors
WorkflowExecutionState(string)
public WorkflowExecutionState(string stateDirectory)
Parameters
stateDirectorystring
Methods
Checkpoint(string, string, string?)
Records a checkpoint for a completed step within a run.
public void Checkpoint(string runId, string stepCorrelationId, string? result = null)
Parameters
Complete(string)
Marks a run as completed successfully.
public void Complete(string runId)
Parameters
runIdstring
Fail(string, string)
Marks a run as failed with an error message.
public void Fail(string runId, string error)
Parameters
GetResumePoint(string, IList<AgentStepDefinition>)
Finds the last incomplete step in a failed run, enabling resume-from-checkpoint. Returns the correlation ID of the step to resume from, or null if all steps completed.
public string? GetResumePoint(string runId, IList<AgentStepDefinition> steps)
Parameters
runIdstringstepsIList<AgentStepDefinition>
Returns
GetRun(string)
Gets the current state of a run.
public ExecutionRun? GetRun(string runId)
Parameters
runIdstring
Returns
ListRuns(string)
Lists all runs for a given workflow.
public IReadOnlyList<ExecutionRun> ListRuns(string workflowName)
Parameters
workflowNamestring
Returns
LoadAsync(string, CancellationToken)
Loads a previously persisted run from disk.
public Task<ExecutionRun?> LoadAsync(string runId, CancellationToken ct = default)
Parameters
runIdstringctCancellationToken
Returns
PersistAsync(string, CancellationToken)
Persists the current run state to disk for crash recovery.
public Task PersistAsync(string runId, CancellationToken ct = default)
Parameters
runIdstringctCancellationToken
Returns
StartRun(string, string, string?)
Starts a new execution run for a workflow.
public ExecutionRun StartRun(string workflowName, string version, string? initiator = null)