How Do Long-Running Agents Use Checkpoints?
How agents save checkpoints during long jobs, what those saves cover and miss, and how to resume safely, explained simply for your AI interview.
In short
A checkpoint is a saved record of an agent's progress at a safe point, so a long job that crashes can resume from its last save instead of starting over. The record must sit in durable storage, and it cannot undo actions the agent already took outside its saved state, such as an email sent.
12 min readAdvancedCommon · estimateFacts checked 26 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
A checkpoint is a saved record of an agent's progress at a safe point. A long job, like moving forty thousand claims over a weekend, saves after each finished claim. If the server crashes, the restart reads the last record and carries on from there. The record must live somewhere durable, such as a database or a disk, not in memory. It can't undo things the agent already did outside its saved state, like an email sent, so I check those before any retry.
Long-running agents are AI jobs that work for minutes, hours or days. They can crash, time out, or be told to slow down by a service, so they need a way to pick up where they stopped. A checkpoint is a saved record of progress, such as the step number, the results so far and the next action. Think of a court clerk who writes the orders and the next hearing date into the case file, so the next session starts from that file.
Here is the AI case. An agent moves forty thousand insurance claims into a new system over a weekend, at about two seconds each. After each finished claim it writes a record to a database. The server restarts just after claim 27,410. The agent reads the record, checks the new system for claim 27,411, and carries on. Without the record, it would start again and could move some claims twice.
Two details matter in an interview. The record must live in durable storage, because a record kept in memory loses everything when the program restarts. And a checkpoint can't undo things done outside its saved state. Restoring files does not reverse an email already sent or a payment already made, so those actions need their own IDs and a check before any retry.
Long runs also need upkeep. Old checkpoints pile up, so I set a rule that deletes old ones on a schedule. For anything that moves money or sends mail, I ask a person to confirm first.
What is a checkpoint, in plain words?
A long-running agent is an AI job that keeps working for minutes, hours or days. It might move a backlog of records, run a large test suite or watch a queue. Such a job can crash, time out, or hit a rate limit (a service asking it to slow down) halfway through, so it needs a way to pick up where it stopped.
A checkpoint is a saved record of that progress, taken at a safe point. The record holds what the next run needs: the step number, the results so far and the next action. It is written somewhere that survives a restart.
Think of a court clerk. At the end of each hearing, the clerk writes the orders made and the next date into the case file. The next session reads the file and picks up there, so nobody re-argues the first day.
Here is the AI version. An agent moves forty thousand insurance claims into a new system over a weekend, one claim at a time. After each finished claim it saves a checkpoint. If the server crashes, the restart reads the last record and carries on with the next claim.
Key words
- Checkpoint
- A saved record of progress, taken at a safe point, so a run can resume.
- Durable storage
- A place that keeps data after the program stops, such as a database or a disk.
- Resume
- Carry on from a saved point, not from step one.
- Side effect
- Something that happens outside the agent's own memory, like an email sent or a payment made.
- Process memory
- The program's own working memory. A restart wipes it.
How does a checkpoint work during a long run?
The agent saves at a safe point: after a step has finished and its result is written down. Saving halfway through a step can store half a change, and the restart would then repeat that change or skip it.
- 1
Pick the save points
Save after each finished unit of work, such as one claim or one test file.
- 2
Write a small record
Store the step number, the results so far, the next action and the IDs of items already done.
- 3
Store it somewhere durable
A database or a disk survives a restart. Process memory does not.
- 4
Load the last record on restart
The agent reads it, checks that the outside world matches it, then carries on from the next step.
One long run with checkpoints
Move 40,000 claims
a job that runs over a weekend
Each finished claim
Move one claim
checked against the new system
Save checkpoint
claim ID, step number, next action
Server restarts
just after claim 27,410
Last checkpoint
the record from claim 27,410
Resume at claim 27,411
finished claims are not moved again
- 1The job starts with the full list of claims.
- 2Each claim is checked, then its record is saved.
- 3The record goes to a database, so it survives a restart.
- 4The crash ends the run. The restart begins from the last saved record.
- 5The restart reads the last record and carries on from the next claim.
With made-up numbers: at about two seconds a claim, 40,000 claims take roughly 22 hours. A crash at hour 15 with no checkpoint means 15 hours of work is redone. With a checkpoint after each claim, the redo is one claim, the one in progress, which the agent checks before it retries.
Here it is in plain Python. A JSON file stands in for durable storage, and a simulated crash stops the run at claim 5.
# A simplified claims mover. A JSON file stands in for durable storage. Rewrites the whole list each step: fine for a demo, not for 40,000 claims.
import json, os, tempfile
STORE = os.path.join(tempfile.mkdtemp(), "checkpoint.json")
def save(step, moved):
with open(STORE, "w") as f:
json.dump({"step": step, "moved": moved}, f)
def load():
if not os.path.exists(STORE):
return {"step": 0, "moved": []}
with open(STORE) as f:
return json.load(f)
def run(claims, crash_at=None):
state = load()
for step in range(state["step"], len(claims)):
if step == crash_at:
return "CRASHED before claim " + str(step + 1)
state["moved"].append(claims[step])
save(step + 1, state["moved"])
return "DONE: " + str(len(state["moved"])) + " claims moved"
claims = ["CL-%04d" % n for n in range(1, 7)]
print(run(claims, crash_at=4))
print(run(claims))Output
CRASHED before claim 5 DONE: 6 claims moved
What kinds of checkpoint are there, and where are they kept?
Three ways agents keep a record of progress show up in real tools, and each saves a different thing, so pick the one that matches what the agent changes.
- Agent state
Saved run state
LangGraph, an agent framework, saves each run's state as checkpoints, so a run can resume after an interruption or a failure.
- Files
File snapshots
The Claude Agent SDK backs up the files that its Write, Edit and NotebookEdit tools (ways an agent edits files) change, then rewinds them on request.
- Code
Git commits
Anthropic's coding harness asks the agent to commit its progress to git, so git can revert a bad change.
Where the checkpoint is kept
Save after each step
the record of progress
Process memory
fast, but gone on restart
Database or disk
kept after a restart
Start again
all progress is lost
Resume
from the last saved step
- 1Option one: the record stays in the program's memory.
- 2Option two: the record goes to a database or a disk.
- 3A restart clears memory, so the job starts from the beginning.
- 4The database still has the record, so the job resumes.
LangGraph's guide makes the same point about its in-memory option:
“MemorySaver and InMemorySaver store checkpoints in RAM. When the process restarts, all checkpoints are lost.”
LangChain, LangGraph persistence
What can a checkpoint not undo?
A checkpoint puts back the agent's saved state. It cannot pull back what already happened outside that state.
“File rewinding restores files on disk to a previous state. It does not rewind the conversation itself.”
Claude Agent SDK, file checkpointing
The SDK's own limits list makes the gaps concrete. Rewinding does not undo changes a shell command (Bash) made, except in files the main conversation had already edited with Write or Edit. It also does not undo creating, moving or deleting directories. Checkpoints are tied to the session that made them, meaning one conversation with the agent.
- 1
Sent emails and payments
Restoring the saved state does not recall an email or a payment. Give each action its own ID, check it before any retry, and ask a person before money moves or mail goes out.
- 2
Checkpoints kept in memory
They vanish on restart, so the record must sit in a database or on disk.
- 3
Piles of old records
Long conversations make many checkpoints. LangGraph's guide notes they can slow the run down and take up storage, so prune them on a schedule.
Tip
Don't say a checkpoint makes a job safe. Say it limits repeated work, then name the actions it cannot undo and how you check them.
How would you make a claims agent safe to restart?
Say the agent moves insurance claims between two systems, and some of those moves trigger payments. My plan has five parts.
- 1
Save after each confirmed claim
The record holds the claim ID and the step number, and it is written only once the new system confirms the move.
- 2
Keep the record in a database
A restart on a different server must still find it.
- 3
Check before every retry
On restart, look up the claim in the new system first. If it is already there, mark it done and move on.
- 4
Gate the payments
Each payment carries an ID and waits for a person's approval, so a repeated run cannot pay twice.
- 5
Break it on purpose
Stop the job at random points in a test run, restart it, and confirm the final count is exactly 40,000.
What does the interviewer want to hear?
A strong answer covers
- A plain definition: a saved record of progress that a run resumes from.
- Where it lives: durable storage, not process memory.
- What it covers: agent state, files or git commits, depending on the tool.
- What it cannot undo: sent emails, payments and changes in other systems.
- Safe restarts: check before a retry, and give actions their own IDs.
- Upkeep: prune old checkpoints on a schedule.
Common traps
Trap"A checkpoint means the job can never repeat work."
BetterIt limits repeated work. Actions outside the saved state can still repeat, so check them first.
Trap"Keeping it in a variable is enough."
BetterA variable lives in process memory and dies with the process. Store the record in a database.
Trap"Rewinding the files also rewinds the chat."
BetterFile rewinding leaves the conversation intact, so the agent still remembers what it tried.
Can you spot the unsafe checkpoint?
Spot the unsafe checkpoint
The job runs on a server that can restart at any time. Which loop is safe to resume after a crash?
Quick check
The process restarts. Its memory is empty, but the checkpoint is in a database. What should the agent do first?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
Last updated on 26 November 2026
Building an agent that runs for hours or days?
I design and build AI products and agents, including the UI and the system behind it. Book a short call and tell me what your agent has to finish, and where it breaks today.