Skip to the workspace
Pebellslearn by building
Agent Memory  ›  Capstone Project

Long-Term Memory — Retrieval and Forgetting

RAG and Vector Databases 15 minLong-term memory stores notes as embeddings so the most relevant can be retrieved by meaning and added to the context, while expiry, recency weighting and consolidation keep stale memories from crowding out current ones.

ai agents / Long-Term Memory — Retrieval and Forgetting

Explore each scene at your own pace.

01 · The rule

The rule

Long-Term Memory — Retrieval and Forgetting

After a year, Tripmate holds hundreds of notes about Asha's trips. When she asks, "What was that quiet hotel near the station in Udaipur?", it cannot paste all of them into the context. It must find the few that matter — and, over time, let go of the ones that no longer do.

The rule

Store by meaning, retrieve the few that matter, and let stale memories fade.

Embeddings make searching by meaning possible. An embedding model turns a piece of text into a long list of numbers — a vector — so that texts with similar meanings get vectors that are close together. "Quiet hotel near Udaipur station" lands near "calm guesthouse, 5 minutes' walk from Udaipur Junction", even though they share few words.

A vector database (or a vector index inside an ordinary database) stores those vectors and quickly finds the ones nearest to a query.

Retrieval-augmented generation (RAG) puts this to work in three steps:

  1. Retrieve — embed the question and fetch the most similar stored notes.
  2. Augment — add those notes to the context.
  3. Generate — the model answers using them, ideally saying which note it relied on.
question → embed → nearest 3 notes → [notes + question] → model → answer

Forgetting keeps long-term memory healthy. Common strategies:

  • Expiry — some memories get an end date (a price quote is stale in a week).
  • Recency weighting — older memories score lower when ranking results.
  • Consolidation — many old episodes are replaced by one summary.
  • Deletion on request — when a user asks to be forgotten, the data goes.
Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.