Lesson 1 of 4 · 35 min

Persist the task, not just the conversation

Build a recovery record with enough information to continue safely.

A transcript tells you what an agent said. A task record tells you what remains true. Long-running work needs both, but they serve different purposes. A conversation can contain outdated plans, failed attempts, and summaries that omit details. Recovery should not depend on asking a model to rediscover the current state from that history.
Separate the objective, constraints, completed artifacts, pending operations, and next permissible transitions. Store versioned references to large artifacts instead of copying their whole content into every message. Keep the operation IDs for external actions. Record whether completion was verified, which verifier checked it, and where the evidence lives. A status such as "done" is useful only when its meaning is precise.
An interrupted task can resume at a safe boundary. For a read-and-draft workflow, that may be after a source has been fetched and stored. For a write, it may require reconciliation before continuation. A checkpoint records application state; it does not retroactively make an external action atomic. The LangGraph persistence documentation distinguishes per-thread checkpoints from cross-thread stores. That distinction helps prevent one user's temporary task state from becoming another task's supposed durable fact.
A compact progress record should preserve decisions and unresolved issues without retaining unnecessary private content. Include source IDs and content hashes when evidence must be reproducible. Keep secrets out of summaries and logs. If an artifact expires or changes, revalidate it. A remembered claim that a room was available yesterday cannot support a booking today.

Worked example

A fictional supplier-review agent must compare four proposals. Its record contains objective O2, criteria version C3, source IDs P1 through P4, completed extracts for P1 and P2, pending extraction for P3, and an unread P4. A report draft references extract hashes H1 and H2. No external write is authorized.
The process stops after P3 extraction but before the report update. On restart, it checks the persisted artifact index. P3's extract exists and passes its schema check, so the task marks extraction complete and rebuilds the comparison from P1 through P3. It reads P4 next. It does not repeat P1 because an old transcript said "I will start with P1". The final completion check requires four extracts and a comparison covering every criterion.

Exercise and solution

A coding assistant has edited three files, run tests that failed, and then lost context. Write the smallest useful handoff record.
A model solution includes the objective and constraints, repository revision, changed-file references, the failing test command and result, the suspected cause labelled as a hypothesis, and the next diagnostic action. It states that the work is incomplete. It does not treat a plan to fix the tests as a completed fix. Award one point each for current artifact state, observed verification result, hypothesis label, and a bounded next step. The record must let a new worker distinguish evidence from intention.

Inspect the restart packet

The following teaching record is deliberately compact. It contains operational facts and artifact references rather than a reconstruction of the model's private reasoning.
code
1task_id: supplier-review-222objective_version: 23criteria_version: 34state_version: 85status: extracting6sources:7  P1: { extract: H1, checked: true }8  P2: { extract: H2, checked: true }9  P3: { extract: H3, checked: false }10  P4: { extract: null, checked: false }11pending_effects: []12next_allowed: validate-P313completion_rule: four checked extracts and criteria-complete comparison
P3 exists but is not yet checked. The correct next transition is validation, not blind acceptance and not necessarily repeated extraction. The distinction prevents a crash between artifact creation and verification from turning an unchecked result into trusted state. If the extract fails validation, preserve the failure reason and repeat only the affected step under the current source version.
The objective and criteria are also versioned. If the user changes the criteria during a pause, earlier extracts may remain useful but the comparison's completeness rule changes. The controller should record the new objective version and identify which prior artifacts require rechecking. It should not erase old evidence or silently pretend the original task was always the new task.

A second worked case: stale artifacts

Suppose proposal P2 changes after its extract H2 is stored. The source service now reports version 7, while H2 records version 6. The task cannot claim that H2 represents current P2. It can either re-extract version 7 or, if the user's request explicitly concerns the earlier proposal snapshot, continue with version 6 and label that scope.
CheckObservationTransition
Artifact integrityH2 matches its stored hashFile itself is intact
Source freshnessP2 is now version 7Prior extract is stale for a current-state task
Objective scopeCompare latest proposalsRe-extract P2 version 7
Prior evidenceVersion 6 remains recordedPreserve as history, not current truth
Integrity and freshness answer different questions. A content hash proves which bytes you have. It does not prove those bytes describe the latest external state. This distinction appears in code checkouts, product prices, room availability, and account permissions. A restart packet should state whether each artifact is a fixed historical input or a current-state observation that can expire.

Choose a safe transition boundary

A task step can contain several internal actions. If extraction writes a file and then indexes it, a crash may leave an orphaned file. The recovery procedure can check whether the file is valid and attach it to the task, or remove it under an explicit cleanup policy. It must not assume that an absent index entry proves no artifact exists.
External writes require an even stronger boundary. A pending provider operation stays in the restart record until reconciled. A model summary saying "the booking probably failed" must not replace that operation's unknown state. This workbook uses read-only supplier extraction to keep the basic state model clear, but the same recovery record must retain effect identities when writes are present.

Misconceptions to reject

"An artifact hash means the information is current" confuses byte identity with external freshness. You can preserve an obsolete proposal perfectly.
"A checkpoint after every model message makes the workflow correct" confuses storage frequency with transition design. A checkpoint can faithfully store an incorrect completion claim or omit an external effect that committed between writes.

Transfer exercise

A report task has five required sections. Three verified section files exist, a fourth file exists without a verification record, and the fifth has not started. The user adds a sixth section while the task is paused. Write the restart decision.
The solution retains the three verified sections if their inputs still match the new scope, validates the fourth, records the fifth and sixth as pending, and updates the completion rule to six verified sections. It preserves the objective change and does not mark the task done because the old plan had only five. Score one point for each state distinction and one for recording the changed objective. Explain which existing artifacts need revalidation if the new section also changes the comparison criteria.

Interview probe

Original practice: Why is a chat summary insufficient for crash recovery? A strong answer names task status, artifact identity, pending effects, and verified transitions. Follow up with an action committed before a checkpoint. A weak answer says to increase the context window.

Sources

docsLangGraph: persistencedocs.langchain.comdocsAnthropic: long-running agent systemsanthropic.com

Checkpoint

P3's extract exists but has no verification record. What should recovery do first?

AMark P3 complete because the file exists.BValidate the existing artifact before accepting or replacing it.CRepeat all four source extractions.DSkip P3 and call the report complete.
Sign up free to answer and see why

Checkpoint

An extract hash matches, but its source advanced from version 6 to 7. What does the matching hash establish?

AThe new source version can be ignored for every task.BThe extract represents the current source.CThe source never changed.DThe stored bytes are the expected artifact, not necessarily current information.
Sign up free to answer and see why

Checkpoint

The user adds a sixth required section during a pause. What should change?

AThe objective version and completion rule, with affected artifacts rechecked.BAll previous artifacts must be deleted.CThe task remains complete under the old five-section rule.DOnly the final response wording.
Sign up free to answer and see why

Checkpoint

A transcript summarizes a provider write as failed, but the persisted operation is unresolved after a timeout. Which state should recovery use?

ATreat the summary as the terminal record because it was written after the timeout.BKeep the provider operation unknown until authoritative reconciliation establishes its effect.CMark the operation failed because the worker exhausted its retry count.DUse the most recent planned next step to infer whether the write completed.
Sign up free to answer and see why

Checkpoint

A crash occurs after a valid artifact is written but before indexing. What is a useful recovery check?

ASearch the bounded task artifact location, validate the file, then reconcile its index.BCreate a new artifact ID without inspecting the old file.CDeclare the extraction complete from the planned filename.DAssume the artifact cannot exist without an index.
Sign up free to answer and see why

Explain how you would resume a changed task from verified and unverified artifacts while checking freshness. Name the record that justifies each transition. Rate confidence from 1 to 5 and state the unresolved boundary.

Not yetGetting thereConfident

Wrap-up

  • Recover from explicit task state. Use the transcript for context and persisted evidence for deciding what to do next.

Sources

Free to read · better with Enzo

Learn it with Enzo

Save your progress, answer the checkpoints, and let Enzo quiz you on what you just read.