CHAPTER 09 · Data Modeling for Agents · 2 / 11
Persist at the edges of the turn
A reliability pattern that's really a data-modeling decision: save the user's message before the model runs, and save the assistant's outcome after. If you only persist at the end, a failed or interrupted turn loses the user's input. By writing the user message immediately, the conversation is durable regardless of what happens during generation. The orchestrator stays a stateless function between these two writes (Chapter 2).