Wiki
Advanced12 min read

Long-term memory

Memory that outlives the session: writing it, consolidating it, and — the part everyone forgets — letting it decay. MemGPT, memory streams, and why forgetting is a feature.

A session ends and the context window is wiped. If the agent should remember the user next time, that memory has to be written to a durable store, retrieved later, and eventually forgotten. Long- term memory turns a stateless model into something that accumulates experience — and inherits all the problems of a system that accumulates anything.

Start here

Long-term memory is a loop, not a bucket: observe something worth keeping, write it, recall it when relevant, and let the unimportant parts fade. Forgetting is not a bug to fix — an agent that remembers everything retrieves noise, pays for it in context, and never develops judgement about what matters.

Gradient strength reaching each earlier time step (right = last step, left = far past).

usable memory horizon ≈ >60 steps

The gradient is below 1% of its strength after the shaded span (63 steps back). Nothing earlier than that is being influenced by what arrived — the mechanism behind untrainable long-range dependencies in plain RNNs.

|factor|^(distance back) on a log scale: the multiplicative anatomy when the same recurrence weights repeat at every unrolled step. Real curves wobble with W_h’s spectrum and gate states, but every honest long-RNN shows a usable horizon of tens of steps — this is why plain RNNs can’t learn long-range dependencies.

Watch stored items lose relevance over time unless they are reinforced.

Two reference designs

  • MemGPT treats the LLM like an operating system: a small "main context" (the window) and a large external "archival" store, with the model paging memory in and out and summarising when the window fills.
  • Generative Agents keep a memory stream of observations, score each by recency, importance, and relevance, and retrieve the top items — with periodic reflection that synthesises higher-level summaries from the raw stream.

Consolidate and forget

  • Consolidation — summarise many raw events into fewer, higher-level memories, the way reflection does. This is compaction applied to a store instead of a transcript.
  • Decay — let importance fade with time unless reinforced, so the store stays a signal of what mattered, not a landfill.
  • Correction — memory must be editable. A wrong memory is trusted precisely because it is remembered.

Careful

Long-term memory is where privacy, staleness, and unbounded growth concentrate. Storing user data raises consent and deletion obligations; an un-editable memory means a mistake persists forever; an un-forgetting store grows until retrieval is useless. Decide what deserves to be remembered and for how long before you build the write path.

Check yourself

Eduspheria wiki · Agentic AI, Memory & context

0 / 4 answered

  1. 1In MemGPT, what plays the role of the fast 'main context'?
    Multiple choice
  2. 2An agent that remembers everything retrieves less noise and develops better judgement.
    True / false
  3. 3What process summarises many raw events into fewer higher-level memories?
    Short answer
  4. 4In Generative Agents, how is each observation scored for retrieval?
    Multiple choice

Next: the engineering of what actually sits in the window.