Skip to content

Durable state, checkpoints and uncertain tool results across sessions

14 min reading

Explain checkpoints, versioned state and uncertain-action recovery across a long session.

Page details

GenAI · Lesson 22 of 45 · 3 / 3.2–3.3

Sources · 14 min reading · 27 min with practice

Published · Last edited:

More
20px

Progress is saved in this browser when storage is available.

View guided paths and progress

Know first: Tool schemas, OpenAPI extraction, runtime validation and action authority. Optional help: GenAI foundations.

Optional background references

Hypothetical scenario. Northwind dispatches a permitted support update, then the worker disappears before recording the response. Maya sees no completion notice. Dev can resume the task from a checkpoint; Priya asks whether that checkpoint describes the external outcome.

Maya: “Should I submit the update again?”

Dev: “We know it was dispatched, but we lack a recorded response.”

Priya: “Preserve that uncertainty and reconcile the operation before creating another effect.”

You will distinguish durable workflow progress from remote action certainty, following checkpoints, operation identity and recovery across sessions. A replacement worker needs evidence for the next transition, not a guess based on an absent response.

What does the checkpoint know about the external action?

A model-driven application mixes several activities: constructing a request, interpreting a response, choosing a tool, waiting for approval and changing an external record. Treating all of that as one function hides the boundaries that matter when execution stops. A local variable can say “sending,” while the document service has already accepted the change. Conversely, a generated sentence saying “updated” can exist before any authorized write was attempted.

The durable-agent introduction established the need for stable action identity and bounded execution. This chapter adds the control structure: which state belongs to the workflow, which transitions are allowed, how parallel updates meet, and where recovery begins. The aim is an inspectable execution model rather than an ever-longer transcript.

Why restarting the whole function loses the distinction

The obvious recovery procedure is to rerun the request from its beginning. That can repeat a model call, obtain a different proposal, consume another attempt and resend an already accepted operation. Another tempting procedure is to trust the latest chat message as the complete state. A message is useful evidence about what was said; it does not identify every pending action, approval version or observation needed for recovery.

Separate those concerns before choosing a framework. Store the approved document revision, proposal identity, remaining task allowance, requested action and confirmed result as different facts. A transition into a confirmed state requires an observation that satisfies the application’s confirmation rule. A timeout instead moves the action into an unresolved state with a reconciliation path.

Store uncertainty as a durable workflow state

Hypothetical scenario. A tool commits an external update, then the workflow crashes before storing the reply. The last checkpoint knows that operation K was dispatched, not that it failed. Resume must recover K rather than replaying the whole task as a new intention.

Store uncertainty as a durable workflow state
ArtifactConcrete evidenceDecision boundary
Checkpointtask state, version, remaining budgetsResume context
Activityoperation K, attempt, dispatched stateExternal uncertainty
Resolutionconclusive evidence or pendingLegal transition
Persist intent before dispatch: Checkpoint → External operation K.Persist intent before dispatch: Checkpoint → External operation K. Checkpoint to External operation K: persist intent before dispatch; External operation K to Recovered evidence: lookup original effect after resume.CheckpointExternal operation KRecovered evidencepersist intent before dispatchlookup original effect after resume
Persist intent before dispatch: Checkpoint → External operation K. Enlarge the diagram to inspect its labels; the surrounding records and explanation give the text alternative.

Persist legal state transitions, approved arguments, attempt evidence and remaining budgets. Deterministic workflow replay reconstructs recorded choices; non-deterministic model and tool activities need recorded results or explicit recovery. A checkpoint alone cannot atomically include an unrelated external service. Cancellation can stop future dispatch while an earlier action remains uncertain, so retain an authorized reconciliation path.

State, nodes and the rule for an update

LangGraph’s Graph API describes workflows using shared state, nodes and edges. Nodes perform work and return updates; edges select subsequent work. A reducer determines how updates to a state field combine. This makes the update rule part of the workflow’s meaning, rather than an incidental assignment in a long procedure.

For Northwind, a proposed design stores one current proposal revision, a set of evidence references and a separate action ledger. Replacing the proposal and appending evidence are different operations. If two branches produce evidence simultaneously, a merge keyed by source identity can be preferable to concatenating arbitrary strings. If two branches propose conflicting replacements, an explicit resolution step is easier to reason about than silently selecting whichever result arrives last.

The reducer is therefore a decision about information. Ask whether order matters, whether duplicate observations should count twice and whether incompatible revisions can coexist. An append-only list preserves history, but it can also repeat the same observation after a retry. A single replacement field stays compact, but can erase evidence of disagreement. Choose each field’s behavior from the reader or decision that consumes it.

Draw the uncertainty into the graph

A write request has a reconciliation branchAn approved proposal leads to write requested. Confirmation leads to complete. A lost response leads to unresolved, then reconciliation. Workflow checkpoints are separate from the document service.Approved proposalrevision fixedWrite requestedaction identity fixedCompleteresult confirmedUnresolvedreconcile outcomeresponse lostA workflow checkpoint is not a remote commit record.

The diagram is a proposed application model, not a claim that these states are built into LangGraph. “Unresolved” is a useful state because it permits inspection without granting permission to repeat the effect. Its outgoing transition must specify the lookup, identity check or human decision needed to establish the next action.

A saved step and an external effect are different records

The official checkpointer guide describes snapshots at super-step boundaries and recovery using saved state. It also distinguishes replay from a prior checkpoint, which re-executes subsequent nodes, from retained successful work in failure recovery. Restoring a checkpoint is consequently not a universal instruction to skip everything that once ran.

Define the meaning of each saved observation in your application. A durable “request prepared” entry can identify what was about to be sent. A durable “response accepted” entry can identify a result the worker observed. There is still an interval between the external effect and the second entry. The document service must supply its own supported operation identity, version condition or authoritative lookup if that interval is to be reconciled automatically.

It helps to divide a node at a meaningful boundary rather than at every line of computation. An independently inspectable proposal is a useful boundary. So is a recorded approval bound to that proposal. A giant node that generates, approves and writes hides several different responsibilities, while excessively fine boundaries enlarge the history without necessarily improving the recovery decision.

Count saved work before claiming a recovery benefit

Hypothetical scenario. Worked example: illustrative arithmetic. Assume a strictly sequential workflow with these chosen durations: collect evidence takes 4 seconds, draft a proposal takes 6 seconds, validate it takes 2 seconds, and the final external write attempt takes 3 seconds. Assume successful checkpoints after each of the first three nodes. Ignore checkpoint latency for this first calculation; these are illustrative durations, not measured framework performance.

The completed prefix takes 4 + 6 + 2 = 12 seconds. The first write attempt adds 3 seconds, so the interruption occurs after 12 + 3 = 15 seconds of attempted work. If the same prefix and one write attempt were blindly repeated, another 15 seconds would be attempted. The cumulative total would be 15 + 15 = 30 seconds, and the external write could have been submitted twice.

Now assume the service supports an authoritative lookup by the stable action identity, and that lookup takes a chosen 1 second. If it confirms the original write, recovery uses 1 additional second and sends no replacement write: 15 + 1 = 16 seconds of cumulative work. If it establishes that the operation did not take effect and permits a safe retry, the extra work is 1 + 3 = 4 seconds, for 15 + 4 = 19 seconds. An inconclusive lookup gives neither conclusion; the workflow remains unresolved.

These totals separate avoided prefix work from effect safety. Reusing 12 seconds of saved computation is useful, but it does not prove whether the first write happened. The service contract supplies that evidence. If the lookup cannot establish absence safely, the 19-second branch is unavailable, regardless of how attractive the estimate looks.

Checkpoint cost changes the calculation

For a second toy estimate, suppose each of the three prefix checkpoints takes 0.1 seconds synchronously. Their added time is 3 × 0.1 = 0.3 seconds, so the first attempt takes 15 + 0.3 = 15.3 seconds under the same serial assumptions. A confirmed-result lookup then gives a cumulative 15.3 + 1 = 16.3 seconds. This is an accounting example, not a recommendation for a particular storage backend.

Suppose a saved state payload is 20 KiB and a selected policy retains 50 snapshots per thread for 100 threads. The raw snapshot payload is 20 × 50 × 100 = 100,000 KiB. Dividing by 1,024 gives 97.65625 MiB. That excludes indexes, task writes, serialization overhead, replication and attachments. It also assumes full snapshots of fixed size. Checkpoint retention is a separate design decision from how long the source document or approval evidence must remain available.

In the wild: why an agent runtime needs recovery

LangChain’s engineering account, Building LangGraph: Designing an Agent Runtime from first principles, explains checkpointing and durable execution as responses to long-running, failure-prone agent execution. It is a first-party design account, not an independent benchmark or a public customer postmortem. Its relevance is the architectural motivation: the unit of recovery should be smaller than restarting an entire expensive task.

The Northwind lost-response incident remains hypothetical. It illustrates an additional boundary the runtime cannot infer from a chat transcript: an external service’s accepted effect may outlive the worker that requested it. Evaluate a runtime by examining its actual persistence contract and your tool boundary together, not by treating the word “durable” as an end-to-end guarantee.

When explicit control helps, and when it becomes ceremony

A graph is useful when the application must expose waiting states, conditional branches or recovery decisions to another person or service. A short, side-effect-free transformation can be clearer as an ordinary function. The point is not to maximize node count. It is to make decisions that survive interruption explicit enough to inspect.

There is also a real choice between a prescribed workflow and model-selected next actions. A workflow can constrain which transitions exist while allowing a model to propose content inside a node. Dynamic planning can handle less predictable tasks, but it creates more possible paths to evaluate. Both still need a task budget, action authority and an observable stopping condition.

For parallel work, distinguish latency from total work. Collecting independent evidence concurrently can shorten a critical path while leaving the number of model calls unchanged. Joining the branches adds a question: which outputs are sufficient, and what happens if one never arrives? A visible join policy is part of the design, not something a state diagram resolves automatically.

Three misleading shortcuts

“The checkpoint proves the document changed.” It proves only the observation represented by that checkpoint under the persistence contract. Match it to authoritative external evidence before declaring the task complete.

“Replaying a graph reproduces the same answer.” If a replay invokes the model again, it is another invocation. Preserve accepted artifacts when their identity matters, and distinguish replaying control flow from reproducing model output.

“A reducer fixes conflicting business decisions.” A reducer implements a combination rule. Appending two incompatible approvals does not decide which proposal may be executed. The application still needs an explicit authority and revision rule.

Limits of the execution model

A state-machine description depends on the real checkpointer, durability configuration, storage failure model and service interfaces. This chapter’s timings and state sizes are selected examples. Framework persistence does not create a transaction across unrelated systems, validate human authority, or establish the truth of remembered content. Review the deployed version’s documented semantics, checkpoint retention and external action contract before relying on a recovery branch.

Test the checkpoint boundary

The checkpoint has no success result. May the resumed agent assume nothing happened?

Reveal the design reasoning

No. Absence of local evidence does not negate a remote effect. Lookup or retry using the original K under the target contract, or retain pending uncertainty.

Decision: Keep intent, effect and knowledge separate across every checkpoint.

Choose the next transition

A restored snapshot says “write requested.” Is another write the next step?

First reconcile the original action using its stable identity and the service’s authoritative mechanism. The snapshot identifies intent, not necessarily the outcome. If the lookup confirms completion, record that result. If it establishes a retry is safe, follow the bounded retry path. If it is inconclusive, preserve an unresolved state rather than guessing.

Two evidence branches return the same document revision. Should the reducer count two independent sources?

No. A chosen append rule can retain both observations, but duplicate identity does not create independent evidence. A merge keyed by document and revision can deduplicate references while retaining branch provenance separately. The reducer should reflect the intended downstream meaning rather than inflate an evidence count.

Why does saving the 12-second prefix not establish a 12-second recovery time?

It identifies computation that need not be repeated under the example’s saved-prefix assumptions. Recovery still needs checkpoint loading, scheduling and external reconciliation. In the toy case the additional lookup is 1 second, making the cumulative total 16 seconds after the first 15-second attempt. That calculation assumes the lookup confirms completion; it is not a measured latency guarantee.

Northwind decision log

  1. Represent proposal, approval, action intent and confirmed result as distinct workflow facts.
  2. Choose checkpoint and merge boundaries from the information needed to resume.
  3. Reconcile uncertain external effects before taking another state transition.

Go deeper: execution history and coordination

Connect the control model to durable task execution and the tool-retry essay. Return to the agentic systems syllabus for the surrounding modules.

Carry the decision forward

Northwind can resume a task without treating uncertain effects as failures. Page 23 asks which records should remain run-local and which deserve promotion into reusable memory.