Agentic AI · Intermediate level

Intermediate level · Module 6: Agent State Management · Lesson 3 of 3

Persistence, Checkpoints and Resuming

Learners save state after each step to SQLite so that tasks can resume after a crash, a power cut or a lost connection, and make steps idempotent.

In this lesson you will

  • Persist state and resume interrupted tasks
  • Make steps idempotent

Key concepts

checkpointserialisation (model_dump_json)resumeidempotencytask ID

The lesson

Save the state as JSON (state.model_dump_json()) to a SQLite table keyed by task ID after every step. If the program stops, reload the latest checkpoint and continue from its status instead of starting again, which saves time and tokens.

A step is idempotent if running it twice gives the same result without side effects. Read-only steps usually are; any future write step must check whether it has already been done before acting.

Checkpoints matter in places where power and connectivity are unreliable, and they also form a durable history of each task.

Step by step

  1. Add a checkpoints table and save state after each step.
  2. Stop the program in the middle of a task.
  3. Resume from the checkpoint and finish.
  4. Show that rerunning a completed step changes nothing.

Practice activity

Add checkpointing and resume to the project agent.

Expected result: Tasks that resume correctly after interruption without repeating completed work.

Check your understanding

  1. What is an idempotent step?

    Show answer

    A step that gives the same result when run twice, without extra side effects.

  2. Why checkpoint agent state?

    Show answer

    To resume after interruptions and keep a durable history.

Further learning

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.