Checkpoint a workflow and resume after failure
In this article (5 sections)
Restarting a workflow from the beginning can repeat tool calls or external writes. A checkpoint records what completed, what failed and which step may safely resume.
Resume without repeating work
The agent controls lab saves an authored failure after validation and lookup.
from agent_cases import checkpoint_case
result = checkpoint_case()
assert result["resume_from"] == "draft"
assert result["repeated_completed_steps"] is False
assert result["resumed_steps"] == ["validate", "lookup", "draft"]The checkpoint includes the lookup idempotency key and temporary timeout. Recovery advances to draft instead of rerunning completed steps.
Persist recovery-critical state
Store run/config version, validated inputs, completed steps, tool receipts, idempotency keys, approvals, next step, attempt budgets and last error. Write checkpoints atomically after a step’s durable effects are known.
Not every step is replay-safe. Mark compensation or verification actions for uncertain outcomes. If a network timeout occurs after a write request, query by idempotency key before retrying.
Test every interruption boundary
Fail before and after each side effect, serialize state and resume with a fresh process. Confirm output equivalence, one side effect and preserved total budgets. Reject resume when code/state versions are incompatible without a migration.
The Generative & Agentic AI course connects checkpoints to idempotency, cancellation and partial-completion runbooks.
Exercise
Checkpoint a four-step workflow after every transition. Inject failures at eight boundaries and prove the recovered result matches a clean run without duplicated writes.
Continue learning
This article is part of the Agent workflows and state sequence. Use the neighbouring tasks when you need the prerequisite or the next application.
- Review the prerequisite or neighbouring task in Design typed state for a multi-step workflow.
- Continue with Idempotency keys for agent tool calls.
Reference: LangGraph persistence.
Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.
This article is part of our Generative & Agentic AI programme — 3 months. Add practical GenAI, retrieval and agent-building skills to your existing toolkit.
Explore Generative & Agentic AI