Course contentsShow
← AI Engineering
Lesson 596 of 1,88615. AI Agents - ArchitectureFree lesson

Short-Term vs Long-Term Memory

Distinguish between conversation context (short-term) and persistent knowledge storage (long-term) in agent systems.

Short-Term vs Long-Term Memory

What you'll learn: How AI agents use different memory types to manage immediate conversation context versus persistent knowledge across sessions.


Just like humans distinguish between remembering what was said two sentences ago (short-term) and recalling facts from years past (long-term), AI agents need both types of memory to function intelligently.

Short-Term Memory: Conversation Context

Short-term memory holds the current conversation's context — the messages exchanged in this session. This is what you've already seen with ConversationBufferMemory and similar patterns. It lives only as long as the agent loop runs.

Think of it like your brain's working memory during a phone call: you remember what the other person just said, the question you asked, and the flow of the conversation. When you hang up, most of those details fade unless you deliberately store them.

Characteristics:

  • Exists within a single session
  • Stored in RAM or temporary variables
  • Lost when the agent process ends
  • Used for coherent multi-turn conversations
  • Subject to context window limits

Long-Term Memory: Persistent Knowledge

Long-term memory is persistent storage that survives across sessions. This could be a vector database of past conversations, a knowledge graph, or even simple file storage. The agent can recall facts, patterns, or decisions from previous interactions — days, weeks, or months ago.

Imagine a customer service agent that remembers you prefer email notifications, even though you told them last month. That's long-term memory at work.

Characteristics:

  • Persists across sessions and restarts
  • Stored in databases, files, or external systems
  • Requires explicit retrieval mechanisms
  • Enables learning from past experiences
  • Grows over time (needs management)

Key Takeaway: Short-term memory maintains conversation flow within a session, while long-term memory stores persistent knowledge across sessions — both are essential for intelligent agent behavior.