Skip to content

Workflows

A workflow is a named bundle of steps with a version. It doesn't run by itself – your runner does.

Why use a workflow

BenefitDescription
Stable identityReplay and audit tied to a consistent ID
VersioningTrack model/prompt changes
Type-safe wiringCommands are validated at compile time

If you only have one step, skip this. The moment you compose steps, it's worth it.

When to use what

Use caseUse
One-off callBare step
Linear flowPipeline
Branching or fan-outCommands
Audit + stable identityWorkflow

Define a workflow

ts
import { defineWorkflow } from "verist";

const workflow = defineWorkflow({
  name: "verify-document",
  version: "1.2.0",
  steps: { extract, verify, score },
});

Type-safe commands

Use workflow.invoke() for type-checked step invocation:

ts
commands: [workflow.invoke("verify", { documentId })],

This catches wiring errors before runtime.

Running a workflow step

A workflow doesn't replace run(). You still call run() with a step, passing identity from the workflow:

ts
const result = await run(
  workflow.getStep("extract"),
  { documentId },
  {
    adapters,
    workflowId: workflow.name,
    workflowVersion: workflow.version,
    runId: "run-42",
  },
);

Versioning

  • Bump versions when a model or prompt change could affect output
  • Keep versions stable across deploys if behavior is unchanged
  • Use semver if that matches your release process

Runner obligations by command

Commands are data. Your runner interprets them. Here's what each command expects:

CommandRunner mustRunner must not
invokeEnqueue the target stepExecute inline without queueing
fanoutEnqueue all items, track completionAssume ordering or atomicity
reviewBlock siblings, await human decisionPersist output before approval
suspendStore checkpoint, stop executionKeep sibling commands (they're stale)
emitDispatch to event bus or webhookTreat as synchronous call

What breaks if you ignore commands

  • Skipped invoke – workflow stalls, dependent steps never run
  • Skipped review – changes ship without human approval
  • Skipped suspend – long-running workflows can't resume
  • Skipped emit – external systems miss notifications

When to skip workflows

If you just need one isolated step (e.g., a single summarizer), skip workflows and use the default identity. You can add a workflow later without rewriting your steps.

LLM context: llms.txt · llms-full.txt
Released under the Apache 2.0 License.