Inside Modern AIPart III · Work That Lasts Longer Than One TurnChapter 9 of 17

State, Checkpoints and Recovery

How complex work survives many steps, asynchronous operations, failures, retries and resumptions

Long-running intelligence is not created by giving a model a large context window. It requires durable state, checkpoints, steering, delegation, permissions, monitoring and recovery. This part explains how those pieces keep an advanced model useful when a task survives many actions, failures and changes of direction. Each chapter asks one question: how does work survive, how does direction change without losing valid work, when should work be divided among several intelligences, and what is the system allowed to do at all.

A short chat can fail and simply be tried again. A long-running task is different. Imagine an AI system that has already inspected a repository, changed twelve files, run several tests, opened a deployment ticket, waited for an external approval, and then encounters a failure. Restarting from the beginning would waste work and may make the situation worse.

How does work survive? Long-running intelligence needs a durable record of what has happened, not just a large amount of text in context.

A Short Reminder: Context and State Are Different

Context is the information currently presented to the model. State is the durable record of where the task stands outside any single inference call: the goal and current plan, completed steps, files or records changed, tool calls still running, results already verified, failures and retry counts, approvals received or still required, and the next safe action.

Context helps the model reason now. State lets the system know what happened before and what remains true after the current model call ends.

Why a Long Context Window Is Not Enough

A system could try to keep the entire history inside the model context. That eventually becomes expensive, noisy and fragile. More importantly, a transcript is not the same thing as operational state. A sentence saying "deployment succeeded" is weaker than a deployment record containing an environment, version, timestamp and verification result. Reliable systems separate conversational history from machine-checkable task state.

Checkpoints Turn Progress Into Something Recoverable

A checkpoint is a known point in a workflow from which the system can safely continue after interruption. For a coding agent, a checkpoint might record the repository commit or patch identifier, tests that passed, tests that still fail, dependencies installed, open tool operations, and the reason the current approach was chosen.

The purpose is not to save every thought. It is to save enough verified state to avoid repeating work or making contradictory changes.

Recovery Requires More Than Retry

A naive agent responds to failure by trying the same step again. That is not recovery. A real recovery loop asks whether the failure was temporary or structural, whether the attempted action changed anything before failing, whether repeating it is safe, whether the system should roll back, continue from partial progress or change plan, and whether a human needs to intervene.

Fable 5.1 is explicitly positioned for long-running work that plans, uses tools and recovers when a step fails. The engineering lesson is that recovery is now part of the expected behavior of a frontier agent, not an exceptional feature.

Idempotency Becomes a Critical Design Pattern

In conventional distributed systems, an idempotent operation can be repeated without causing duplicate side effects. The same idea becomes essential for agents. If a payment step times out after the request reaches the bank, retrying blindly could pay twice. If a ticket-creation tool times out, retrying might create duplicate tickets.

The application should therefore use identifiers, transaction records and duplicate protection so the agent can ask "Did this already happen?" before repeating an action. Every long-running workflow should identify which actions are safely repeatable and which require evidence before retry.

Asynchronous Work Creates Pending State

Astra supports asynchronous tool calling: the model can continue reasoning or work on independent tasks while an application-level tool is still running. That creates a new category of state, pending work. The system must know which operation is still running, which call identifier belongs to it, which decisions depend on its result, whether later work can proceed safely without it, and what to do if it never returns. This resembles distributed software more than a traditional chat application.

Compaction and Checkpoints Solve Different Problems

Compaction, introduced in Chapter 1, reduces how much historical information must remain in active context. A checkpoint preserves the operational truth needed to resume work. A compacted summary might say "authentication refactor is complete and tests pass." A checkpoint records the exact commit, test command, test result, environment and timestamp.

The first helps the model reason efficiently. The second helps the system prove what actually happened.

Durable State Should Prefer Facts Over Narratives

Whenever possible, state should be stored in structured fields rather than only in free-form summaries:

status = awaiting_approval

last_verified_commit = abc123

pending_tool_call = inventory_scan_47

retry_count = 1

rollback_available = true

The model can still receive a readable summary, but the application preserves the machine-checkable facts separately, so a later decision can be checked against a value rather than a sentence.

Under the Hood

A durable agent loop can be represented as:

1. Load authoritative task state.

2. Reconstruct only the context needed for the next step.

3. Let the model choose a plan or action.

4. Validate permissions and preconditions.

5. Execute the action.

6. Verify the resulting external state.

7. Write a checkpoint.

8. Record pending work or failure information.

9. Continue, recover, or escalate.

Three distinctions live in this loop. Step 2 is where compaction applies: context is rebuilt, not accumulated. Step 7 is the checkpoint, and it comes after step 6, never before; a checkpoint written before verification records a hope, not a fact. Step 4 is where duplicate protection and idempotency preconditions are checked before execution: the system asks whether the action already happened before it lets it happen again.

Where It Can Still Fail

Success is checkpointed before it is verified. The record says done; the external system disagrees.

A retry repeats an irreversible action. The step was not idempotent and nobody checked.

State goes stale. Another system changed the environment after the state was read.

Summary and store disagree. The compacted narrative contradicts the authoritative record, and the model believes the narrative.

A valid checkpoint is no longer relevant. Requirements changed, and the system resumes from progress that no longer applies. Chapter 10 takes up that case.

The move from chat to long-running work turns AI engineering into distributed-systems engineering.

Reliable autonomy depends on state, idempotency, checkpoints, verification and recovery as much as it depends on model intelligence.

Three Things to Remember, One Thing to Do

1. Context is temporary working information; state is durable operational truth.

2. Recovery means understanding what changed, not merely retrying.

3. Long-running AI should checkpoint verified progress so failures do not erase or duplicate work.

One thing to do. Take one agent workflow you run or plan to run and write its state as structured fields, using the block above as a template. Then list every action the agent can take and mark each as safe to retry or needs evidence before retry. The second list is your idempotency backlog.

How much do you need? Platform/DevOps: Master · Developer: Use · Architect: Use · Security: Use. Everyone else: Know.

Report a correction

Corrections go to the editor and are never published automatically. No account needed.