Lesson 1: Keeping a run's state safe through a crash
28 min read·13 Oct 2026
Module 8 · Lesson 1 · About 55 minutes · Needs: Module 5 (Lesson 1, the loop; Lesson 3, the SQLite checkpointer) and the shared data's compact tools (make_tools,run_tool; Module 3 builds their final form)
The situation
It is Tuesday 26 May 2026, week 7. Dev is moving the agent onto a worker that is redeployed twice a day. "Every deploy kills whatever is running. Say the agent is halfway through R-1004: Mei Tanaka cancelling her SoundPod headphones, order 8204, $79.00. What happens when it starts again?"
Marta is sharper: "If the refund went through just before the restart, I do not want it paid twice."
Module 5 saved a run while it waited for a person. This lesson saves it after every turn and makes replaying a turn harmless.