Skip to content
agentskit.js

Durable execution

Persist side-effectful steps and replay completed work after a restart.

Durable execution is a small step-log wrapper. It is not a separate workflow engine: keep the business workflow in JavaScript and mark side effects with a stable stepId.

#File-backed example

import { createDurableRunner, createFileStepLog } from '@agentskit/runtime'

const store = await createFileStepLog('.agentskit/steps.jsonl')
const durable = createDurableRunner({ store, runId: 'order-42' })

const draft = await durable.step('draft', () => createDraft())
const sent = await durable.step('send', () => sendEmail(draft))
console.log(sent)

On restart, the same runId and stepId replay recorded successes without executing the function again. Use createInMemoryStepLog() for tests and single-process experiments.

#Contract

  • Step functions may perform side effects; their returned value is persisted.
  • Stable step IDs are required for deterministic replay.
  • Failed steps are recorded and fail future calls for the same run until the run is reset or a new run ID is chosen.
  • Calls for the same step ID on one runner are single-flight. Distributed stores still need an atomic claim/append primitive before sharing a run across processes.
  • durable.history() reads the current run and durable.reset() removes it.

The file log is JSONL. A missing file is initialized; malformed records fail closed with a durability error instead of being treated as an empty history.

Explore nearby

Ask the docs
Ask anything about AgentsKit. Answers come from the docs corpus and cite their sources.