> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentium.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Workflows

> Public workflows signatures and configuration in @agentium/core 4.0.0.

Import these **12 exports** from `@agentium/core`. Read the [workflows guide](/workflows/overview) for setup and behavior, or return to the [package reference](/api-reference/core).

A `?` marks an optional field. These are declarations for lookup; run the examples in the linked guide. Follow related-type links for Agentium types and source links for imported dependency types.

## AgentStep

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/workflow/types.ts)

```typescript theme={null}
export interface AgentStep<TState> {
    name: string;
    agent: Agent;
    inputFrom?: (state: TState) => string;
}
```

Related: [`Agent`](/api-reference/core/agent#agent).

## ConditionStep

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/workflow/types.ts)

```typescript theme={null}
export interface ConditionStep<TState> {
    name: string;
    condition: (state: TState) => boolean;
    steps: StepDef<TState>[];
}
```

Related: [`StepDef`](/api-reference/core/workflow#stepdef).

## FunctionStep

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/workflow/types.ts)

```typescript theme={null}
export interface FunctionStep<TState> {
    name: string;
    run: (state: TState, ctx: RunContext) => Promise<Partial<TState>>;
}
```

Related: [`RunContext`](/api-reference/core/agent#runcontext).

## ParallelStep

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/workflow/types.ts)

```typescript theme={null}
export interface ParallelStep<TState> {
    name: string;
    parallel: StepDef<TState>[];
}
```

Related: [`StepDef`](/api-reference/core/workflow#stepdef).

## StepDef

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/workflow/types.ts)

```typescript theme={null}
export type StepDef<TState> = AgentStep<TState> | FunctionStep<TState> | ConditionStep<TState> | ParallelStep<TState>;
```

Related: [`AgentStep`](/api-reference/core/workflow#agentstep), [`ConditionStep`](/api-reference/core/workflow#conditionstep), [`FunctionStep`](/api-reference/core/workflow#functionstep), [`ParallelStep`](/api-reference/core/workflow#parallelstep).

## StepResult

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/workflow/types.ts)

```typescript theme={null}
export interface StepResult {
    stepName: string;
    status: "done" | "error" | "skipped";
    error?: string;
    durationMs: number;
}
```

## StorageBackedCheckpointStore

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/workflow/checkpoints.ts)

```typescript theme={null}
/**
 * Default checkpoint store backed by a `StorageDriver`. Use any existing driver
 * (in-memory, SQLite, Postgres, MongoDB, Redis, ...) to get persistence.
 */
export declare class StorageBackedCheckpointStore<TState> implements WorkflowCheckpointStore<TState> {
    /** Maximum number of checkpoints kept per run. Older ones are deleted. */
    readonly keepLastN: number;
    constructor(storage: StorageDriver, options?: {
        keepLastN?: number;
    });
    save(cp: WorkflowCheckpoint<TState>): Promise<void>;
    load(checkpointId: string): Promise<WorkflowCheckpoint<TState> | null>;
    listForRun(runId: string): Promise<WorkflowCheckpoint<TState>[]>;
    delete(checkpointId: string): Promise<void>;
}
```

Related: [`StorageDriver`](/api-reference/core/storage#storagedriver), [`WorkflowCheckpoint`](/api-reference/core/workflow#workflowcheckpoint), [`WorkflowCheckpointStore`](/api-reference/core/workflow#workflowcheckpointstore).

## Workflow

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/workflow/workflow.ts)

```typescript theme={null}
export declare class Workflow<TState extends Record<string, unknown> = Record<string, unknown>> {
    readonly kind: "workflow";
    readonly name: string;
    readonly eventBus: EventBus;
    constructor(config: WorkflowConfig<TState>);
    run(opts?: RunOpts & {
        initialState?: Partial<TState>;
    }): Promise<WorkflowResult<TState>>;
    /**
     * Same as `run()` but additionally saves a `WorkflowCheckpoint` after every
     * top-level step. Requires `checkpointStore` in the config.
     */
    runWithCheckpoints(opts?: {
        sessionId?: string;
        userId?: string;
    }): Promise<WorkflowResult<TState> & {
        runId: string;
    }>;
    /** List all checkpoints for a given runId. */
    listCheckpoints(runId: string): Promise<WorkflowCheckpoint<TState>[]>;
    /**
     * Replay the workflow from the state captured at `checkpointId`. Continues
     * with the remaining steps. Returns the final result + new run id.
     */
    replay(checkpointId: string): Promise<WorkflowResult<TState> & {
        runId: string;
    }>;
    /**
     * Fork a workflow run from a checkpoint with optional state mutations. The
     * fork gets a fresh runId. Use this for branching ("what if step 3 said X?").
     */
    fork(checkpointId: string, mutations?: (state: TState) => TState | Partial<TState>): Promise<WorkflowResult<TState> & {
        runId: string;
    }>;
}
```

Related: [`EventBus`](/api-reference/core/events#eventbus), [`RunOpts`](/api-reference/core/agent#runopts), [`WorkflowCheckpoint`](/api-reference/core/workflow#workflowcheckpoint), [`WorkflowConfig`](/api-reference/core/workflow#workflowconfig), [`WorkflowResult`](/api-reference/core/workflow#workflowresult).

## WorkflowCheckpoint

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/workflow/checkpoints.ts)

```typescript theme={null}
/**
 * Per-step workflow checkpoint. Captures the state immediately after a step
 * completed so the workflow can replay or fork from that exact point.
 */
export interface WorkflowCheckpoint<TState> {
    /** Stable identifier - `${runId}:${stepIndex}`. */
    id: string;
    runId: string;
    workflowName: string;
    stepIndex: number;
    /** Name of the step whose completion produced this checkpoint. */
    stepName: string;
    /** State immediately AFTER the step ran. */
    state: TState;
    /** Cumulative step results up to and including this step. */
    stepResults: StepResult[];
    timestamp: number;
}
```

Related: [`StepResult`](/api-reference/core/workflow#stepresult).

## WorkflowCheckpointStore

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/workflow/checkpoints.ts)

```typescript theme={null}
export interface WorkflowCheckpointStore<TState> {
    save(checkpoint: WorkflowCheckpoint<TState>): Promise<void>;
    load(checkpointId: string): Promise<WorkflowCheckpoint<TState> | null>;
    listForRun(runId: string): Promise<WorkflowCheckpoint<TState>[]>;
    delete(checkpointId: string): Promise<void>;
}
```

Related: [`WorkflowCheckpoint`](/api-reference/core/workflow#workflowcheckpoint).

## WorkflowConfig

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/workflow/types.ts)

```typescript theme={null}
export interface WorkflowConfig<TState extends Record<string, unknown> = Record<string, unknown>> {
    name: string;
    initialState: TState;
    steps: StepDef<TState>[];
    storage?: StorageDriver;
    retryPolicy?: {
        maxRetries: number;
        backoffMs: number;
    };
    eventBus?: EventBus;
    /** Auto-register this workflow in the global registry. Default: true. Set false to opt out. */
    register?: boolean;
    /**
     * Enable time-travel: automatically checkpoint state after each step so the
     * workflow can be replayed or forked from any point.
     */
    checkpointStore?: WorkflowCheckpointStore<TState>;
}
```

Related: [`EventBus`](/api-reference/core/events#eventbus), [`StepDef`](/api-reference/core/workflow#stepdef), [`StorageDriver`](/api-reference/core/storage#storagedriver), [`WorkflowCheckpointStore`](/api-reference/core/workflow#workflowcheckpointstore).

## WorkflowResult

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/workflow/types.ts)

```typescript theme={null}
export interface WorkflowResult<TState> {
    state: TState;
    stepResults: StepResult[];
}
```

Related: [`StepResult`](/api-reference/core/workflow#stepresult).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.