Agents · Module 07
Agent Memory Systems
How an agent remembers across turns and sessions: kinds of memory, patterns to implement them, a production memory platform, and the mistakes to avoid.
Học xong bạn làm được
- Explain why agents need memory beyond the context window
- Tell working, semantic, episodic and procedural memory apart
- Implement common memory patterns
- Avoid memory anti-patterns in production
Bài học
- Why memory matters
An agent without memory is a goldfish - every turn starts fresh, mistakes repeat and preferences must be restated. Memory gives continuity within a session, learning from past interactions, personalisation and the resumption of long-running tasks, so the agent behaves less like a stateless API and more like a knowledgeable colleague.
- Memory taxonomy
Agent memory has four types - working memory (the context window, finite and lost at the end unless checkpointed), semantic memory (long-term facts in vector or key-value stores), episodic memory (records of past interactions, what worked and what failed) and procedural memory (stored workflows and learned skills, versioned).
- Implementation patterns
Four patterns build agent memory - LangGraph thread checkpoints for working memory within one conversation, the LangGraph Store for cross-thread facts under namespaces, a vector store for semantic retrieval at scale with selective storage, and episodic memory saved as summaries rather than raw transcripts.
- Mem0 and memory anti-patterns
Mem0, published at ECAI 2025, packages memory extraction, storage and retrieval behind one SDK - automatic extraction, semantic deduplication, update-or-replace conflict resolution, graph and procedural memory; add() and search() cover the loop. Six anti-patterns - storing everything, no decay, no conflict resolution, mixed memory types, a flat namespace, no retrieval filter - each have a fix.
- Memory in production
In production, memory needs a GDPR deletion path, data minimisation and consent, timestamps and confidence decay against staleness, ANN indexes, partitioning by user and caching for scale, and its own evaluation - Recall@K, Precision@K, task improvement and freshness. Effective memory combines working, semantic, episodic and procedural memory, storing only what matters.