DEV Community

Cover image for AI Agents Need More Than Memory: They Need Checkpoints
Arif Sefa
Arif Sefa

Posted on Edited on

AI Agents Need More Than Memory: They Need Checkpoints

Imagine an AI agent that analyzes a request, calls several tools, delegates work to other agents, and produces a result. In development, everything works. Then, in production, the server restarts halfway through the workflow. Does the agent continue where it stopped, repeat every previous operation, lose the user's approval, or, worst of all, execute a payment twice?

Checkpointing is one of the mechanisms that answers these questions. As AI systems move from simple chat interfaces to long-running, tool-using workflows, it becomes a core part of production architecture.

1. What Is Checkpointing?

A checkpoint is a persisted snapshot of an agent's execution state at a specific point in time. It lets the system restore progress instead of starting over, much like saving a game instead of replaying from the first level.

Consider a customer support agent handling a refund:

  1. Identify the customer.
  2. Retrieve the order.
  3. Check the refund policy.
  4. Calculate the refund amount.
  5. Request manager approval.
  6. Execute the refund.
  7. Notify the customer.

If the server restarts after step 5, a system without checkpointing repeats everything, and may even ask the manager to approve again. With checkpointing, it restores the state and continues from the approval stage. We are not saving the conversation; we are saving the progress of the task.

2. Conversation Memory Is Not Workflow State

Conversation memory records what the user and agent discussed. Workflow state records what the system has actually completed.

Suppose a user asks an agent to analyze a repository and open a pull request with fixes. The agent finds three issues, generates changes, runs tests, and opens the PR. If the application crashes right after the tests pass, the conversation history alone cannot answer:

  • Which files were modified?
  • Which tests ran, and did they pass?
  • Was the pull request actually created?
  • Which commit belongs to this task?

These are execution-state questions. A useful way to separate the concepts:

Concept What it answers
Conversation memory What was discussed?
Workflow state Which steps are done, running, or pending?
Checkpoint The durable, versioned copy of workflow state that survives a restart
External system state What actually happened in other systems (payments, repos, tickets)?

A reliable agent has to reconcile all four, especially the last one, because external systems are the source of truth for side effects.

3. What Happens When an Agent Crashes?

Take a payment agent:

Receive payment request
        |
        v
Validate customer
        |
        v
Check account balance
        |
        v
Execute payment
        |
        v
Send confirmation
Enter fullscreen mode Exit fullscreen mode

The payment succeeds, but the application crashes before the next checkpoint is saved. On restart, the last checkpoint says "payment execution is pending," so the agent may pay again and the customer is charged twice.

Checkpointing alone is not enough here; we also need idempotency. Every payment gets a unique operation ID that is passed along with the request:

{
  "operationId": "payment-12345",
  "customerId": "customer-789",
  "amount": 250,
  "status": "COMPLETED"
}
Enter fullscreen mode Exit fullscreen mode

The crucial detail is where the check happens. If only the agent's own state knows about payment-12345, the same crash window remains. The idempotency key should be enforced by the system that performs the side effect (the payment provider or ledger), so a retry returns the original result instead of charging again. It also helps to record the intent ("about to execute payment-12345") before calling the provider, so that after a restart the agent knows the operation may already have happened and should look it up instead of blindly retrying.

The principle: checkpointing preserves workflow progress; idempotency protects external operations from being repeated. Production systems need both.

4. The Atomicity Gap

A subtler problem sits between the two: you cannot atomically commit "the side effect happened" and "the checkpoint was saved" across two different systems. There is always a window where one is true and the other is not.

Because of that, recovery logic should assume that any step marked "in progress" may or may not have taken effect. The safe patterns are to make such steps idempotent, to verify against the external system before retrying, or to route ambiguous cases to a human.

5. Checkpointing in Multi-Agent Workflows

Checkpointing gets more interesting when several agents collaborate:

             Task Planner
                  |
          +-------+-------+
          |       |       |
       Backend  Frontend  Security
        Agent    Agent     Agent
          |       |       |
          +-------+-------+
                  |
              Test Agent
                  |
              Review Agent
                  |
              Final Result
Enter fullscreen mode Exit fullscreen mode

If the Backend Agent finishes but the Security Agent fails, re-running everything would waste time and money. We should persist completed work and resume only what is unfinished:

{
  "workflowId": "task-1001",
  "status": "RUNNING",
  "agents": {
    "planner": { "status": "COMPLETED" },
    "backend": { "status": "COMPLETED", "output": "backend-result.json" },
    "frontend": { "status": "COMPLETED", "output": "frontend-result.json" },
    "security": { "status": "FAILED", "attempts": 1 },
    "testing": { "status": "PENDING" }
  }
}
Enter fullscreen mode Exit fullscreen mode

After recovery, the planner, backend, and frontend agents do not run again. The security agent resumes according to its recovery policy (retry with backoff, skip with a recorded reason, or escalate to a human), and testing starts only when all of its dependencies have completed.

This matters most when agents perform expensive work such as repository analysis, large document processing, or many LLM calls. The orchestrator must still handle dependencies, partial failures, and the fan-in step correctly. Restoring a shared state object does not by itself guarantee that every worker's result is handled properly.

6. Human-in-the-Loop: Checkpoints as Approval Boundaries

Not every workflow should run autonomously. Consider an agent that reviews a software architecture: it analyzes the diagram, identifies services and dependencies, generates security findings, requests human approval, and then writes the final report.

At the approval step, the workflow pauses and saves its state. The engineer reviews the findings the next morning and approves, and the workflow resumes from that checkpoint without repeating the analysis.

RUNNING
   |
   v
WAITING_FOR_APPROVAL
   |
   +---- REJECTED ----> CANCELLED
   |
   +---- APPROVED ----> RESUMED
                            |
                            v
                         COMPLETED
Enter fullscreen mode Exit fullscreen mode

Two design points deserve attention:

  • Who defines the boundary: Approval boundaries should be enforced by the application or orchestrator, not left to the LLM. An agent should not decide on its own whether a high-impact financial operation needs approval.
  • What was approved: Time passes while a workflow waits. Bind the approval to a specific checkpoint version, so the human approves exactly what will be executed, and consider an expiry, so a stale approval is not honored days later after the underlying data has changed.

7. When Should We Create a Checkpoint?

Saving after every tiny operation adds storage and latency overhead. Saving too rarely increases the work lost after a failure. Useful boundaries include:

  • After an expensive LLM operation.
  • After a successful tool execution.
  • After an agent completes its responsibility.
  • Before waiting for external input or human approval.
  • After receiving an external event.
  • Before executing a high-impact operation.

A document-processing agent may checkpoint after every chunk, while a simple classification agent may only need to save the final result. Granularity should match the cost of repeating work and the consequences of losing progress.

8. What Should a Checkpoint Contain?

A checkpoint should hold enough information to recover reliably:

{
  "workflowId": "workflow-1001",
  "version": 2,
  "status": "WAITING_FOR_APPROVAL",
  "currentStep": "human_approval",
  "completedSteps": [
    "repository_analysis",
    "dependency_scan",
    "security_review"
  ],
  "pendingSteps": [
    "final_report"
  ],
  "artifacts": {
    "analysis": "storage/analysis.json",
    "scan": "storage/scan.json",
    "findings": "storage/findings.json"
  },
  "approval": {
    "required": true,
    "status": "PENDING",
    "approvedVersion": null
  },
  "updatedAt": "2026-11-29T10:00:00Z"
}
Enter fullscreen mode Exit fullscreen mode

Things worth considering:

  • Completeness: Store what is needed to continue, not just the last LLM response.
  • Versioning: Workflow definitions and state schemas can change between deployments, so a checkpoint written by an old version must still be loadable or safely rejected.
  • Agent identity: Record which agent produced each result.
  • Idempotency: Keep operation IDs so repeated operations are safe.
  • Durability: Use durable storage, not process memory.
  • Retention: Avoid keeping sensitive data longer than necessary.

Also, don't blindly persist every raw LLM message. Prefer structured outputs, references to artifacts, execution metadata, and the minimum context needed for recovery.

9. Frameworks and Implementations

Several frameworks and infrastructure projects address persistence and recovery, at different layers. Check each project's current documentation for exact capabilities, since this area changes quickly:

  • LangGraph offers checkpoint-based persistence for graph execution, including interrupts and resuming after human input.
  • Microsoft Agent Framework provides workflow checkpointing aimed at restoring long-running workflows after restarts.
  • Spring AI can be combined with an orchestrator and persisted workflow state to implement pause-and-resume patterns.
  • Infrastructure-level approaches, such as projects that checkpoint process memory for stateful agents on Kubernetes, recover a running process rather than a workflow definition.

Application-level checkpoints (what step are we on?) and infrastructure-level recovery (restore this process) are not interchangeable. The first knows the meaning of your workflow; the second knows nothing about it, and neither one replaces idempotency.

Conclusion

Building an agent that completes a task is one challenge. Building one that completes it despite crashes, deployments, network failures, and human interruptions is another. As agents become more autonomous and workflows longer, we have to design for failure, not only for prompts, tools, and model choice.

A production-ready agent should know what to do next, what it has already done, what is still pending, and what is safe to execute again.

Top comments (0)