Lv.1 0 XP

State Persistence — Saving and Restoring Agent State Across Sessions

Core 6 min +25 XP
💡
THE ANALOGY

A surgeon's pre-op notes. Before every procedure, they review the chart: patient history, current medications, known allergies, prior surgeries. They don't rely on memory between visits. Agent state persistence is building and maintaining that chart — structured, retrievable, always current.

⚠️ EXAM TRAP — The Wrong Answer People Choose

Persisting the raw conversation history and treating it as equivalent to structured state. Raw conversation history is verbose and slow to inject. Structured state (key decisions, confirmed facts, task progress) is compact and precise.

KEY POINTS
1 Persist structured state, not raw conversation: decisions made, facts confirmed, tasks completed, current progress.
2 Checkpoint after every significant operation — not just at the end.
3 State must be rehydratable: loading saved state must produce the same agent behavior as if the session never stopped.
4 Separate fast state (current session, in memory) from slow state (cross-session, in storage).
5 State expiration: long-abandoned state may be stale — check timestamps before rehydrating.