Skip to main content

Workflow steps

A durable workflow step runs a named unit of work and saves its result. On a later run with the same workflow ID, step name, stable step key, and input, ISH reuses that result instead of running the step again. This helps long pipelines continue after a restart. If the process stops during an external request, check whether that request succeeded before retrying. Keep step inputs and outputs in JSON format, a text format for common values such as objects, lists, numbers, and strings.

from ish import SQLiteLogger, step, workflow

logger = SQLiteLogger(db_path="./data/workflow.db")


@step(retries=2, backoff_seconds=0.5, backoff_factor=2.0)
async def fetch_record(record_id: str) -> dict[str, str]:
# Make this safe to repeat if it changes an external system.
return {"id": record_id, "status": "ready"}


@workflow(name="record_pipeline", persistence=logger)
async def record_pipeline(record_id: str) -> dict[str, str]:
return await fetch_record(record_id, step_key=f"fetch-{record_id}")

Choose a stable replay key​

By default, a step is identified by its name, position, and input. Supply an explicit step_key when identity should remain stable as you reorder code. Reusing a key with changed input is rejected rather than returning an old result.

Use an existing step store​

If your application already stores step records, supply a workflow persistence adapter with three functions: read a step result, reserve a new step so only one worker runs it, and save its result. Python exposes WorkflowAdapterPersistence; the Rust API accepts a DurableStepStore (including CallbackStepStore); the TypeScript, Go, C#, and Java PersistenceStore wrappers expose fromWorkflowAdapter, NewWorkflowAdapterPersistenceStore, FromWorkflowAdapter, and fromWorkflowAdapter, respectively. Pass the store to DurableWorkflow as you would a regular persistence store. The shared runtime decides whether to reuse, start, pause, or finish a step. The supplied functions access your storage and must reserve each step without allowing two workers to start it at once.

This three-callback adapter supports durable host steps. To persist traces, session messages, agent checkpoints, and declarative workflow control flow, use the full StorageConnector contract or SQLite WAL.

Handle retries​

Retries are useful for temporary failures, but a function that changes an external system must be safe to repeat. Use a request ID supported by that service or check its status before retrying payments, deployments, and similar actions.

SituationRecommended approach
Temporary network or service failureConfigure bounded retries and backoff
Repeatable external requestReuse a provider-supported idempotency key
External result is unknown after a crashCheck provider status before retrying
Step needs a person to decidePause for approval and resume later

See Durable Replay for recovery behavior and the API reference for step options.