New Tool Radar

AI Agents & Automation

How to Restart an Agent Run Without a Duplicate Write After a Crash

Restart a crashed agent run safely by checking which writes already landed before re-running any step.

Schematic with three steps: Read the checkpoint and list the completed; Check the external system for each write; Resume from the first unwritten step.

A crash in the middle of a run leaves a dangerous question: which steps already wrote, and which did not? Restarting from the top without checking repeats the writes that already landed. LangGraph’s checkpointer saves the graph state so a run can resume later, even from an error state, and its interrupt rules warn that side effects before a pause re-run on resume, so they must be idempotent or placed after the pause. Before you restart, read the external system for what already exists, skip the steps that already wrote, and only then resume. A restart that checks first is a recovery; one that does not is a duplicate.

What you need

  • A crashed agent run with a checkpoint or run log you can read
  • A way to check the external system for writes that already landed
  • A list of the run’s write steps, in order

Step 1: Read the checkpoint and list the completed writes

Open the checkpoint or run log and list which write steps completed before the crash. A step with no record is unknown, not done.

Step 2: Check the external system for each write

For each write step, check the external system: does the record exist? If it does, skip that step on restart; if it does not, the step is safe to run.

Step 3: Resume from the first unwritten step

Restart the run from the first step that did not write, using the same thread or session id so the checkpoint is found. Confirm afterwards that each write exists exactly once.

Worked example: synthetic crash restart

The table below is a synthetic example. It shows the expected result of a safe restart; no run was crashed.

Write step Already landed? Action on restart
Create the invoice Yes Skip
Send the invoice email No Run
Log the delivery No Run
Each write exists once Yes Pass

Expected result (UNTESTED). the restart skips the invoice that already exists, runs the two steps that did not, and every write exists exactly once. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • A step with no record is unknown, not done; guessing wrong creates a duplicate or a gap.
  • An in-memory checkpointer loses the state on a crash, so a durable one is needed for real recovery.
  • Writes without a unique key cannot be checked for duplicates, so add one before relying on restarts.
  • Resuming re-runs the paused node from the top, so work before a pause must be safe to repeat.

Sources

See all