Home/Agentic AI/Memory Types/Long-Term Memory

Memory Types

Understand how AI agents store, retrieve, and manage information across different memory systems

Long-Term Memory: Persistent Storage

Long-term memory lets agents remember information across sessions. Unlike the context window that resets, long-term storage persists indefinitely in databases, vector stores, or file systems. This enables agents to build continuous learning and maintain user relationships over time.

Three Types of Long-Term Memory

Episodic Memory (Conversation History)

Stores specific interactions with timestamps and context. "What did the user say on Tuesday?" This is your agent's personal diary.

Example Structure:
timestamp: 2024-11-16 14:30:22
user: "What's the weather tomorrow?"
agent: "Tomorrow will be sunny, 72°F"
context: casual_chat, location: SF
timestamp: 2024-11-16 15:45:10
user: "Book me a flight to NY"
agent: "I found 3 flights. Prefer morning?"
context: booking, urgency: medium
Storage Method
  • • SQL database with timestamps
  • • NoSQL (MongoDB, DynamoDB)
  • • Append-only event logs
Use Cases
  • • "What did we discuss last time?"
  • • Personalization over time
  • • Audit trails and debugging

Interactive: Memory Scale Impact

See how memory size affects storage and retrieval performance

100
1010K100K
Storage Size
200 KB
Approximate total
Search Time
46 ms
Vector similarity
Retrieval Cost
Low
Per query

Recommendation:

Good scale for personal assistants. Fast queries, low costs.

Long-Term Memory Design Patterns

Best Practices

  • Use embeddings for semantic search
  • Add timestamps and metadata to all memories
  • Implement memory decay (older = less relevant)
  • Allow users to delete/correct memories (privacy)

Common Pitfalls

  • Storing too much irrelevant information
  • No expiration policy (database bloat)
  • Slow retrieval without proper indexing
  • Forgetting privacy and data retention laws