CourseAgentic AI Engineer: The Complete Course · Module 8: Memory and State · part 47 of 97
Part 47 · Module 8: Memory and State

Lab: Checkpoints, resumable runs and a careful memory

41 min read·13 Oct 2026
Module 8 · Lab · About 75 minutes · Needs: the Module 3 lab's tools.py, Module 5's loop (Lesson 1), and lessons 1 and 2 (RunRecord, Checkpoints, run_checkpointed and idempotency keys; the memory gate, remember, recall and forget)

What you are building

RETURNS-DESK/ AFTER THIS LAB model scripted or real state.py run state | careful memory tools.py Module 3's memory/ Chroma, local BrightCartSystems state.db SQLite 2 tests
The finished piece: one new file of your code (blue) keeps each run's state in state.db and the customers' memories in a local folder, and calls BrightCart only through Module 3's tools.py (grey, unchanged).

This lab moves both lessons' code into one file, returns_desk/state.py, which imports Module 3's tools.py and never replaces it. Its first half keeps a run safe: a run record beside the transcript, a checkpoint after every turn in SQLite, a resume after a crash, and an idempotency key on every write that leaves BrightCart, the email included. Its second half is a careful memory: a gate on what may be stored, a scope taken from the session, recall as data, superseding and forgetting. Tests pin both halves. Everything at BrightCart is simulated.

The rest of this course is yours to keep

This course is bought on its own, once, and stays readable afterwards, including the parts added to it later.