Memory
| Short Term Memory | Long Term Memory |
|---|
| Psychology | lasts for 15-30 seconds | lasts for more than 30 seconds |
| LLM | current session | shared across multiple sessions |
Short Term Memory
- aka Thread scoped memory or working memory
- tracks ongoing conversation by maintaining message history
- LangGraph uses State and Checkpointer to achieve this
Long Term Memory
- user specific or application data
- shared across conversational threads
- can be implemented with Vector Stores
- Based on Human Psychology LTM is classified further
- Types
- Semantic Memory
- Episodic Memory
- Procedural Memory
- LTM implementation depends on
- what kind of memory?
- when do you want to update the memories?
- in the hot path
- background async
| LTM Type | What is Stored | Psychology Example | Agent Example |
|---|
| Semantic | Facts | Things I learned in school | Facts about a user |
| Episodic | Experiences | Things I did | Past agent actions |
| Procedural | Instructions/ Rules | Instincts or motor skills | Agent system prompt |
Semantic Memory
- can be implemented by semantic search by vector DB
- fact based, when and how does not matter
- examples
- user preferences
- domain knowledge
Episodic Memory
- can be implemented by key-value structured DB
- save memories as episodes indexed by time and topic
- what happened when type questions
- examples
- multi-sessions to remember previous sessions
- coaching agents to track progress over time
Procedural Memory
- handled by fine tuning and prompts
- capture “how-to” knowledge
- examples
- reusable skills
- multi-steps tasks like data pipelines or API integrations
Cognitive Architectures
Memory Consolidation
- Merge, deduplicate, and strengthen memories
Memory Compaction
- Compress stored memories with summaries, entity extraction, or distillation
Memory Decay
- Give more weight to recent memories compared to old memories
- Versioning of memories can help
- Forget on purpose
Production
- Caching frequently used memories
- TTL policies to remove stale memories
- Horizontal sharding
- Backup and Recovery
- GDPR and PII
- Observability
- Cost management