Table of Contents

Class WorkflowExecutionState

Namespace
JD.AI.Workflows.Consensus
Assembly
JD.AI.Workflows.dll

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

stateDirectory string

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

runId string
stepCorrelationId string
result string

Complete(string)

Marks a run as completed successfully.

public void Complete(string runId)

Parameters

runId string

Fail(string, string)

Marks a run as failed with an error message.

public void Fail(string runId, string error)

Parameters

runId string
error string

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

runId string
steps IList<AgentStepDefinition>

Returns

string

GetRun(string)

Gets the current state of a run.

public ExecutionRun? GetRun(string runId)

Parameters

runId string

Returns

ExecutionRun

ListRuns(string)

Lists all runs for a given workflow.

public IReadOnlyList<ExecutionRun> ListRuns(string workflowName)

Parameters

workflowName string

Returns

IReadOnlyList<ExecutionRun>

LoadAsync(string, CancellationToken)

Loads a previously persisted run from disk.

public Task<ExecutionRun?> LoadAsync(string runId, CancellationToken ct = default)

Parameters

runId string
ct CancellationToken

Returns

Task<ExecutionRun>

PersistAsync(string, CancellationToken)

Persists the current run state to disk for crash recovery.

public Task PersistAsync(string runId, CancellationToken ct = default)

Parameters

runId string
ct CancellationToken

Returns

Task

StartRun(string, string, string?)

Starts a new execution run for a workflow.

public ExecutionRun StartRun(string workflowName, string version, string? initiator = null)

Parameters

workflowName string
version string
initiator string

Returns

ExecutionRun