Checkpointing Agent Runs
In this article
- Explain why an agent run that waits or works for a long time needs its progress saved outside the process that runs it.
- Place two checkpoints around a refund call, one before and one after, under a single run id.
- Say what a restart should do when the process dies before, between or after those two checkpoints.
- Spot a restart design that would pay a customer twice or forget a pending approval.
- Terms defined here: durable execution, checkpoint, durable run identity, action intent, tool receipt.
Overview
Your support agent has started a refund. A manager has to approve it first, and the approval comes back hours later. In the meantime you ship a new version and the server restarts. The program that started the refund is gone. When a fresh process picks the work up, does it pay the customer, pay them twice, or forget the refund entirely?
The answer depends on what was written down, and where, before the process died. By the end you can place two save points around a call that moves money, read what was saved, and say what a restart must do when the crash lands before, between or after them. You will also see the one gap those save points cannot close.
A run outlives its process
An agent run is a sequence of steps: read something, decide, call a tool, wait, call another tool. Some runs finish in seconds. Others wait a day for a person, and AWS Lambda durable functions can keep one execution going for up to a year. [2] No server process is sure to live that long. Deploys and crashes end processes all the time, so the run's run state, the record that lets it continue where it stopped, has to live somewhere else.
Memory inside the process does not count. LangGraph's in-memory checkpointers keep saved state in RAM and lose all of it when the process restarts; for production it points to a database-backed saver such as PostgresSaver. [4] A runtime that saves progress outside the process and picks it up after an interruption gives you durable execution. On Lambda, a durable execution tracks its progress with saved checkpoints and, after an interruption, uses the stored results of finished operations instead of running them again. [2]
Here is the run we will follow, a made-up example. An online shop's support agent refunds customers with three tools: get_order reads an order, create_refund pays money back, and send_receipt emails the customer. Refunds above 40.00 EUR wait for a manager, and the create_refund code enforces that limit. Run r-7f3 handles order 1042 in four steps: 1 get_order(1042), 2 wait for approval, 3 create_refund(1042, 49.00), 4 send_receipt.
Restarting without checkpoints
Suppose nothing is saved. The new process has two options, and both fail. It can start the run from step 1: if the old process had already paid, step 3 pays 49.00 EUR a second time. Or it can hand the model the conversation so far and let it work out what happened: if the crash came after the refund went out but before its reply was added to the history, the history shows no refund and the model sends it again.
LangGraph documents the same shape: a node calls a payment API, the payment succeeds, the process crashes, and the retried node pays again. [3] The side effect happened in the outside world; the record of it died with the process. The same loss repeats an email when the crash lands after send_receipt.
What a checkpoint holds
A checkpoint is a saved snapshot of the run's state at a step boundary, written somewhere that survives the process. LangGraph, a library that runs an agent as a graph of steps called nodes, saves one at every super-step, its name for one round in which the graph runs each node due at that point, and a resume loads the latest one saved. [1]
Two rules make a checkpoint trustworthy. First, it is authoritative state for what the run did: the runtime's own code writes it and reads it to decide what a restart does. The model never decides whether a refund already happened. For what happened in the outside system, that system is authoritative, not the checkpoint. Second, the prompt history is not the record of what ran. It is text for the model, and it can miss the one call you need to know about.
The checkpoint is stored under a durable run identity, here r-7f3. The id is created once, when the run starts, and every process that ever touches the run uses the same one. Lose it and the new process cannot find the saved state at all.
:::note In practice: LangGraph files every checkpoint under a thread_id; with no thread_id it can neither save state nor resume. [1] To resume a run that stopped early, you invoke the graph again with the same thread_id, and it loads the latest checkpoint. [1,3] :::
Two checkpoints around the refund
Checkpoints go wherever a crash would leave you unable to tell what happened. For r-7f3, that is around step 3, the one call that moves money.
When step 2 ends, the row already holds the step cursor, the number of the next step to run, set to 3, and the approval. The first save of the refund comes just before the call. It adds an action intent: the row says create_refund(1042, 49.00) is about to go out. The second save comes right after the call returns. It records a tool receipt: the refund id that create_refund returned, with the cursor moved to 4. Both rows carry the run id r-7f3.
In pseudo-code, the writes and the restart branch look like this:
save(run="r-7f3", cursor=3, approval="approved")
save(run="r-7f3", cursor=3, intent="create_refund(1042, 49.00)")
result = create_refund(1042, 49.00)
save(run="r-7f3", cursor=4, receipt=result.refund_id)
on start:
row = load("r-7f3")
if row.cursor == 3 and row.intent is empty: run step 3
if row.cursor == 3 and row.intent is set: outcome uncertain: confirm, send nothing yet
if row.cursor == 4: skip step 3, run send_receiptEach save must finish before the next line starts. LangGraph lets you choose when it writes checkpoints: in Python, its "sync" durability mode finishes each write before the next step begins, while "exit" saves only when the run ends, so a crash mid-run leaves nothing to recover from. [1]
Three places to die
Before reading the table, decide what a restart should do if the process dies at each point: (a) before the intent is saved, (b) after the intent is saved but before the receipt, (c) after the receipt is saved.
The stored row for r-7f3 at each kill point, and what the restart does with it:
| kill point | step cursor | intent | receipt id | approval state | restart does |
|---|---|---|---|---|---|
| (a) before intent | 3 | empty | empty | approved | Sends step 3. No call went out. |
| (b) intent, no receipt | 3 | saved | empty | approved | Outcome uncertain. Ask the provider whether this exact refund happened before sending anything. |
| (c) after receipt | 4 | saved | saved | approved | Skips create_refund, runs send_receipt. |
Row (a) is safe because an empty intent proves the call never started. Row (c) is safe because the receipt proves the money moved. Without checkpoints, both (b) and (c) would have paid again.
Row (b) is the hard one. The intent says the call was about to go out; the missing receipt says nothing came back. The refund may have gone through with its reply lost, or it may never have left. From the row alone you cannot tell, so the rule is: confirm, never resend blindly. Confirming means asking the system that did the work whether the action happened, here by asking the payment provider whether this exact refund happened; the next lesson shows how.
The two checkpoints shrink the doubt from "anywhere in the run" to one short window around one call. They do not remove it: the payment commits on someone else's server, and no save of yours can land at that instant.
The wait is state too
The approval column matters as much as the cursor. Suppose the process dies during step 2, while the run waits for the manager. If the row holds the cursor but no approval state, a restart cannot tell "still waiting" from "approved", and code that moves on pays without the approval the shop requires. With "pending" saved, the restart goes back to waiting.
Durable runtimes treat a wait as saved state; a Lambda durable function suspends during a wait without compute charges. [2] Who may approve, and how, comes later in the course.
:::note In an interview: "Checkpoint before and after every call that changes the outside world, keyed by a run id, and let code, not the model, decide the restart." The trade-off to name: the window between the two saves is still uncertain, so the restart confirms before it repeats anything. :::
Common mistakes
- Treating the chat history as the log. Symptom: after a crash the model re-sends a refund because its reply never reached the history. Fix: write the intent and receipt rows from code and branch on them.
- Saving only after the call. Symptom: a crash during the call leaves a row that still says "step 2 done", and the restart pays again. Fix: save the intent before the call, so window (b) is visible.
- Keeping checkpoints in memory. Symptom: every deploy forgets all runs in progress. Fix: a saver backed by a database; LangGraph's in-memory one loses everything on restart. [4]
In production
In LangGraph, the framework checkpoints its own steps, not your side effects: it writes checkpoints at super-step boundaries, not in the middle of a function, and payments, emails and other external writes inside a node fall outside that boundary, so your code must make them safe to repeat. [3] Google's ADK can resume a stopped workflow when you mark the app resumable, using the Invocation ID of that workflow instance. [5]
Claude Code's checkpoints are a different thing: they save your files before each prompt so you can rewind edits, and they do not resume a run. [6]
The row records what the run did, not what is true now. The order read in step 1 may be hours old when step 3 runs, so a decision based on it can rest on stale state; handling that comes later in the course.
Sources
- Checkpointers (LangGraph docs). LangChain. Checked 25 Oct 2026.
- Lambda durable functions. AWS. Checked 21 Nov 2026.
- LangGraph: Fault tolerance. LangChain. Checked 25 Oct 2026.
- Persistence (LangGraph docs). LangChain (langchain-ai/docs). Checked 25 Oct 2026.
- Resume stopped agents (ADK docs). Google. Checked 21 Nov 2026.
- Checkpointing. Anthropic. Checked 24 Oct 2026.
Check yourself
Check yourself
Question 1 of 13
A support agent's run waits a day for a human. Where should its progress be saved?
Your first check counts towards your result.