Long-term Memory (Agent)
Close a chat and the model forgets you. That is fine for a one-off question and useless for an assistant meant to work alongside you for months. Long-term memory is the store that persists outside any single run — facts, preferences and lessons the agent writes down deliberately so a later session can retrieve them.
How it is actually built
Nothing is remembered by the model itself; the weights do not change. Memory is a store plus the discipline of writing to it:
- a write step that decides what from this run is worth keeping — a stated preference, a project constraint, an approach that failed;
- a store: rows in a table, documents, or embeddings in a vector store for similarity search;
- a retrieval step on later turns that pulls back the few relevant entries and places them in the context window;
- maintenance — deduplicating, updating a fact that changed, expiring what no longer holds.
Short-term and working memory hold the current conversation and the current task; long-term memory is what survives both. Frameworks expose it as a store you attach to the agent — LangGraph's persisted stores, or the project conventions a coding agent carries between sessions.
Why it matters
It turns repetition into accumulation. Without it an agent asks the same clarifying questions every morning, re-derives the same dead end, and cannot improve from experience. Done carelessly it is worse than nothing: one stale entry, retrieved confidently, quietly poisons every plan built on top of it.
Long-term memory is an agent's persistent store of facts, preferences and lessons, kept outside the context window and retrieved into it when relevant. Unlike short-term memory, it survives across sessions, letting an agent accumulate knowledge of a user or a project instead of restarting cold each time. Its risk is staleness: an outdated entry, retrieved confidently, corrupts the reasoning that depends on it.
Imagine an assistant who is brilliant for an hour and then forgets you completely — every single day. You would spend every morning explaining your job, your preferences, and the mistakes not to repeat.
Long-term memory is what stops that. The AI keeps a notebook outside the conversation: things worth remembering about you, about the project, and about what has already been tried. Next time it looks up the few notes that matter and reads them before starting work.
That is how these systems become more useful the longer you use them. It also means an out-of-date note can mislead them, so a well-built one updates and prunes what it has written down.