# Durable Workflow Snapshot

> Serialize full workflow state to pluggable durable storage at checkpoints so long-running, multi-day tasks survive deploys, process restarts, and host crashes.

- **Category**: Agentic AI
- **Subcategory**: Governance & Observability
- **Canonical URL**: https://designpattern.fyi/patterns/durable_workflow_snapshot/

---

## Description
**Intent**: Capture workflow execution state as a snapshot in pluggable storage so a paused run can resume across deployments, process restarts, and host crashes.
**Context**: Workflows that run for hours or days — waiting on a human approval, a slow third-party API, or a scheduled wake-up — must survive application deploys, worker restarts, and host loss. The team has access to durable storage and can't afford to lose in-flight work.
**Solution**: Treat the workflow runtime as a fully serializable state machine. At checkpoints (after every step, on suspend, before risky actions) write a snapshot — `{step_index, local_state, awaited_signals, history}` — to a pluggable storage provider (Postgres, S3, Redis, or vendor-managed). To resume, load the snapshot, rehydrate state, and continue from the recorded step. Version snapshot schemas and refuse to resume incompatible versions rather than silently corrupting the run.



## Use Cases
- Runs span deploys (anything longer than a typical release cycle).
- Workflows may pause minutes-to-hours on external signals (human approvals, slow APIs).
- Host loss must not lose user work.
- An audit trail of intermediate state is required.






## Trade-offs


### Advantages

- Runs survive deployments, process restarts, and host loss completely transparently.

- Pluggable storage lets the same workflow run against different durability tiers.

- Snapshots are inspectable artifacts — resume is observable and debuggable.

- Long suspensions (human approval, slow APIs) are cheap — no compute spend while waiting.




### Considerations & Drawbacks

- Snapshot schema versioning is real engineering work; version mismatches must fail closed, not silently corrupt.

- Storage I/O on each checkpoint adds latency and cost.

- Resuming a snapshot under different code may reach states the new code doesn't expect.

- Sensitive data in snapshots inherits the storage provider's access-control posture.







---
**Reference**: [Original Source](https://www.agentpatternscatalog.org/patterns/durable-workflow-snapshot/)

