Recorder

Snapshot the state so the run can be resumed, not restarted.

The system state (including reasoning and world model) is explicitly captured and externalized so a run can be recovered, resumed, or replayed across steps, sessions, and processes — not only after an abort.

In practiceWhen a batch-extraction agent crashes mid-run, the recorder's persisted step log lets a fresh instance skip the API calls already completed and continue from the point of failure.

Level
04 · Production
Subdomain
Memory Architecture
Also known as
State Saver, Explicit State Capture
Trade-off
Increased resilience and resumability are gained against higher storage costs and persistence overhead.
Native in
LangGraph, Microsoft Agent Framework
The mechanism

How it works.

After every step the complete state is written to a store outside the process, under the ID of the run. Any later process can load the latest snapshot and continue from there.

1 · Capture, after every step

  1. Step finishedThe state has changed
  2. Take a snapshotValues, next step, metadata
  3. Durable storeKeyed by the thread ID

2 · Restore, in a new process

  1. Crash or pauseThe process is gone
  2. Load the latest snapshotFound by the thread ID
  3. Skip finished workCompleted steps do not run again
  4. ContinueFrom the step that was open
Resume
Load the latest snapshot and finish the unfinished work.
Replay
Start again from an earlier snapshot. Every step after it runs again, model calls included.
Fork
Change the state at a snapshot. This creates a new snapshot; the original stays untouched.
Walk it through

A real run, step by step.

TaskA batch agent extracts fields from 500 invoices in two batches and writes a CSV file. The process crashes at invoice 380.
StepSnapshotAfter restart
1 · Load 500 invoicesSavedNot repeated
2 · Extract invoices 1 to 250SavedNot repeated; 250 model calls kept
3 · Extract invoices 251 to 500None; crash at invoice 380Repeated from invoice 251
4 · Write the CSV fileNot reachedRuns
What this shows: recovery is as fine-grained as the snapshots. 130 calls run twice because one step covered 250 invoices. Anything a repeated step does to the outside world also happens twice, so such steps must be safe to repeat.
In code

The pattern in code.

Plain Pythonpython
def run(thread_id, steps):
    # a fresh process starts here
    state, done = store.latest(thread_id) or ({}, 0)
    for i, step in enumerate(steps[done:], start=done):
        state = step(state)
        # one snapshot per finished step
        store.save(thread_id, state, next_step=i + 1)
    return state
Fit

Use it, or not.

When to reach for it

  • State loss in long-running or resource-intensive workflows is critical and must be prevented.

When it backfires

  • Tasks are short, stateless, or easily repeatable from scratch.
Pitfalls

Two ways this pattern will hurt you.

Snapshots persist sensitive intermediate state

Every checkpoint includes whatever lived in working state — including PII or secrets the agent saw transiently while reasoning.

Countermeasure

Define a serialization contract that strips sensitive fields before persistence. Validate the contract with a test that diffs serialized state against an allowlist.

Replay diverges because the world moved on

The step log records the inputs but re-executes tools on resume. An external result that has since changed makes the resumed run diverge from the one that was interrupted.

Countermeasure

Memoize side-effecting tool outputs in the record and replay them, rather than re-calling; mark genuinely non-replayable steps so resume restarts from the last safe boundary.

Framework support

Where Recorder is native.

LangGraphCheckpointersNative
Microsoft Agent Frameworkdurable run stateNative

Search

Search patterns, frameworks, and pages.