Modern AI Engineering

Lesson 11.7 · 25 min · video lesson

Agent Memory: Short-Term, Long-Term, and Episodic

An LLM forgets everything the moment a call ends; so how does an assistant remember that you are vegetarian three weeks later?

In short: LLMs are stateless, so agent memory is something we build around the model. It forms a stack: the context window as working memory, the session history as short-term memory, and external stores as long-term memory (facts, past episodes and procedures). Memory systems run four core operations, write, read, update and forget, and the hard part is choosing what is worth remembering and retrieving only what helps the current task.

What you will learn

  • The Big Picture
  • Why AI Agents Need Memory
  • The Memory Stack
  • The Four Core Operations
  • How Memory Flows at Runtime
  • What to Store and What Not to Store
  • Common Mistakes and How to Fix Them
  • Quick Summary

In this lesson

  1. The big picture
  2. Why AI agents need memory
  3. The memory stack
  4. The four core operations
  5. How memory flows at runtime
  6. What to store and what not to store
  7. Common mistakes and how to fix them
  8. Worked example, step by step
  9. Practice: try it yourself

Key terms in this lesson

Stateless
Keeping no information between calls; each LLM call sees only what is in its prompt.
Working memory
The content of the context window for the current model call.
Semantic memory
Long-term facts and preferences, such as “the user is vegetarian”.
Episodic memory
Long-term records of specific past events or interactions, usually timestamped.
Procedural memory
Knowledge of how to do things, stored as instructions, rules or reusable skills.
Memory consolidation
Merging, correcting and summarising stored memories so they stay consistent and compact.

This lesson is part of the Generative AI Engineering and Complete AI Engineer tracks. See plans and pricing to open the full lesson, its video, labs and quiz, or try the free lesson first (free account needed).

← 11.6 Reflection Agents: Self-Critique for Higher-Quality Outputs · 11.8 Model Context Protocol: A Standard Interface for Agent Tools →