Memory & State
Short- and long-term memory, agentic memory, semantic caching and state management.
- lessons
- 6
- steps
- 53
- time
- 69 min
Memory Architectures
Split an agent's memory into working, episodic and semantic tiers, decide when memories move between them, and prove each layer beats plain retrieval.
- Why a 1M-token window is not a memory strategy
- The three tiers: working, episodic and semantic memory
- When memory belongs in files instead of a vector index
- Write-time, sleep-time and read-time consolidation
Short-Term Context Management
Keep the context window lean, cacheable and append-only: paged KV memory, prefix caching, sliding windows, summaries and selective dropping.
- Model window vs application window, and why you leave a buffer
- How paging cut KV-cache waste from 60–80% to under 4%
- Order prompts static-first so the prefix cache hits
- Sliding window, summary, hybrid and provider compaction
Long-Term Memory
Persist what an agent learns across sessions: episodic logs, extracted facts, vector-graph hybrids, decay and forgetting, and hard tenant isolation.
- Three shapes of long-term memory service
- Episodic trajectories vs extracted semantic facts
- When a real graph earns its cost over entity-aware vectors
- Decay, consolidation and explicit forgetting
Agentic Memory with Mem0
Turn conversations into a self-updating user profile: Mem0's extract-store-retrieve loop, where conflict handling went in v2, and how to pick a memory layer.
- Why Mem0 stores insights instead of transcripts
- The v2 write path: one extraction call, ADD-only, hash dedup
- Where contradictions get resolved now
- Wiring Mem0 into a LangGraph agent
Semantic Caching
Reuse whole answers for equivalent questions: the embed-search-threshold pipeline, false hits, scoping, and when a provider prompt cache already wins.
- Why exact-match caches miss most repeated questions
- The pipeline: embed, search, threshold, verify, update
- Semantic drift: how a loose threshold returns wrong answers
- Semantic cache vs provider prompt cache
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.
- Why state should be typed and append-only
- Checkpoint, crash, resume — and the side-effect trap
- Fork/join with reducers instead of overwrites
- Time travel is a fork, not an edit