Memory & Stateintermediate12 min · 9 steps
State Management Patterns
Give an agent a typed, append-only state, run it as a graph, checkpoint every step, fork and join with reducers, and choose who holds the state.
datarequesttool callresponse
ProblemStep 1 of 9
A while loop crashes at step 6
Production agents run for minutes or hours. A plain while loop keeps everything in process memory: the plan, the tool results, the conversation.
When the server restarts at step 6, all of it is gone. The run starts over, repeats every tool call, and the user who was promised a result in ten minutes waits again.
Watch outRepeated tool calls are not just slow: a refund or an email sent twice is a real-world bug.
Lesson 6 of 6 in Memory & State