i Informopedia.com
Artificial Intelligence Tier 1 · Public

Short-Term vs Long-Term Memory in AI Agents: A Complete Guide

2,858 words 14 min read Updated December 1, 2026

Ask an AI agent a question, close the tab, and come back tomorrow: it will not remember you. The language model underneath is stateless — every call starts from zero. And yet the agents people actually use do remember your preferences, your decisions, your project. That memory is not built into the model. It is a layer built around it, and it comes in two kinds.

Short-term memory keeps a single task coherent. Long-term memory lets an agent carry what it learned into the next session, and the one after that. For years, that split was the standard way to describe agent memory — but a major survey published in December 2025 argues it no longer describes what real systems do. This guide covers both kinds of memory, the three forms of long-term memory, the systems builders use today, and the trade-offs nobody puts in the marketing copy.

If you are new to agents themselves, start with our What Is Artificial Intelligence? The Complete Guide.

Why AI agents need memory at all

A large language model is a function: text goes in, text comes out, and nothing is kept. Close the conversation and the model forgets everything. An agent is a loop wrapped around that function: it plans, calls tools, observes results, and repeats. Memory is what makes that loop coherent over time.

A 47-author survey, “Memory in the Age of AI Agents” (Hu et al., December 2025, revised January 2026), puts it cleanly: memory is the agent’s evolving state, a persistent, self-improving substrate holding facts and the traces of past experience. Without it, an agent is a brilliant amnesiac — capable in the moment, useless across days. With it, the same model becomes a colleague that knows your work.

What short-term memory is

Short-term memory — usually called working memory — is everything the model can “see” in a single inference call: the system prompt, the conversation so far, the reasoning trace, the tool outputs, and any documents retrieved for this turn. It lives inside the context window, the finite amount of text a model can consider at once. When the session ends, it is gone, unless something writes part of it somewhere more permanent first.

Think of it as RAM: fast, directly available, and gone on shutdown. Everything the agent is doing right now depends on it — the plan it is halfway through, the results of the tool it just called, the constraint you stated two messages ago. Lose the thread and the agent repeats itself or quietly drops a step.

The hard limit is the context window. Frontier models now advertise windows from 200,000 tokens to 1 million. But a bigger window is not a better memory. Research by Chroma in 2025, testing 18 leading models, found accuracy can start degrading well before a model runs out of room — sometimes as early as 50,000 tokens into a 200,000-token window. “Lost in the Middle” (Liu et al., 2023) showed the same pattern: models use information at the beginning and end of a long context far better than information buried in the middle.

What long-term memory is

Long-term memory is what survives past the current run. It lives outside the model — typically in a database, a vector store, or a knowledge graph — and the agent queries it the way it would query any other tool. When you return a week later and the agent still knows you prefer concise summaries and that your project deadline is Friday, that is long-term memory doing its job.

It differs from retrieval-augmented generation (RAG) in one respect: the content. RAG retrieves an organisation’s reference documents; long-term memory retrieves the agent’s own accumulated history. The infrastructure is often identical, but what is stored is different. Our guide to RAG failure modes covers the retrieval side in depth; the failure patterns overlap heavily, because both systems live or die by what they retrieve.

Short-term vs long-term memory at a glance

Short-term (working) memory Long-term memory
Where it lives Inside the model’s context window Outside the model — vector store, graph, or database
What it holds Current conversation, reasoning trace, tool outputs Facts, past events, preferences, skills learned earlier
How long it lasts One session or task, then gone Across sessions — days, months, indefinitely
How it is read Already in the prompt; no retrieval needed Queried by meaning (semantic search) or graph traversal
What breaks first Context-window limits; “lost in the middle” Stale facts, retrieval misses, conflicting memories
Analogy RAM — fast, temporary, lost on shutdown Hard disk — persistent, queryable, survives reboots

The three kinds of long-term memory

Long-term memory is not one thing. Borrowing terms from cognitive science, researchers split it into three kinds, and a good memory system needs all three.

Episodic memory records specific past events: what a customer asked last time, what was decided in a prior meeting, which approach failed on Tuesday. Episodes are timestamped and often tagged with their outcome, so the agent learns from what happened, not just what was said.

Semantic memory is generalised knowledge distilled from those episodes: facts about the user, the project, or the world the agent works in. “The user prefers concise summaries” is semantic; “on 14 November the user asked for a concise summary” is episodic.

Procedural memory is knowledge of how to do things: the workflow for onboarding a client, the tool sequence that reliably books a flight, the format the team expects in a weekly report. It is the kind most often missing from early memory systems — which is why agents keep re-deriving the same routines from scratch.

Beyond short vs long: the 2026 taxonomy

Here the field has moved past the vocabulary this guide started with. The Hu et al. survey argues that “short-term versus long-term” is a usage pattern, not a taxonomy — two systems can both claim “long-term memory” while one dumps dialogue into a vector database, another edits adapter weights, and a third compresses key-value caches. The survey organises memory along three axes instead.

Forms — what carries the memory. Token-level memory stores discrete, human-readable text in an external store: chunks, JSON records, graph nodes. Parametric memory writes knowledge into the model’s weights, through fine-tuning or adapters — powerful, but hard to update. Latent memory stores compressed representations in hidden states or key-value caches.

Functions — what job the memory does. Factual memory holds knowledge, experiential memory holds the traces of past interactions, and working memory holds the active state of the current task. “Working memory” here is a function, not a place: the same fact can serve as working memory during a task and become factual memory afterwards.

Dynamics — how memory changes over time. Formation decides what becomes a memory candidate; evolution merges, revises, and forgets, resolving conflicts when new facts contradict old ones; retrieval builds a query from the current situation and returns the memories that matter. Short-term and long-term effects are not separate modules here: they emerge from when formation, evolution, and retrieval happen — at the start of a task, continuously inside it, or across tasks over weeks.

For anyone choosing or building a system, these three axes are the useful questions: what form does it use, which function is it serving, and how does it handle the lifecycle — especially forgetting, where most systems are weakest.

How long-term memory actually works

Behind every long-term memory system is the same write–read loop, and its asymmetry explains most of the engineering trade-offs: writes are slow and batched; reads are fast and constant.

Writing happens after the action. The system extracts salient facts from the conversation — not the transcript, but distilled statements like “the user’s project deadline is Friday.” Those facts are consolidated against what is already stored: duplicates merged, contradictions resolved, outdated entries updated or invalidated. Then they are embedded and indexed so they can be found by meaning later. Because extraction and consolidation need model calls of their own, writes usually run in the background.

Reading happens on every turn. Before the model responds, the system queries the store for memories relevant to the current message — by semantic similarity, recency, and importance — and injects the best few into the prompt. A good retrieval step is invisible; a bad one is worse than none, because stale memories actively mislead the model.

Forgetting is the neglected half of the loop. Memories decay, get summarised into higher-level facts, or are deleted outright — by the user, by policy, or because they conflict with newer information. An agent that never forgets accumulates contradictions until its answers become unreliable. Forgetting is not a bug; it keeps memory trustworthy.

Neurons in a mouse brain slice with Nissl staining, magnified 100 times
Neurons in a mouse brain slice with Nissl staining, magnified 100 times. Biological memory lives in networks like this; agent memory systems imitate the pattern — storing connected facts and retrieving them by association. Image: Ns takes photos, CC BY 4.0, via Wikimedia Commons.

The memory systems builders actually use

Five open-source systems dominate the conversation in 2026 — and they are not competitors on the same axis. Choosing between them is choosing an architecture.

Mem0 is the most widely adopted memory layer: an add/search API that extracts facts from conversations and hands them back at prompt time, with an optional graph memory. Apache 2.0 licensed, with more than 60,000 GitHub stars, it drops into an existing agent with the least integration work. Its team reports that on the LoCoMo benchmark it beat OpenAI’s memory feature by 26% relative accuracy, cut 95th-percentile latency by about 91% versus stuffing full history into context, and used around 90% fewer tokens — vendor-reported, but the direction matches independent reports.

Letta is a stateful agent runtime, not a memory library, descended from MemGPT (Packer et al., 2023; arXiv:2310.08560). Where Mem0 is a service the agent calls, Letta makes memory management the agent’s own job: the model holds editable memory blocks in its context window and rewrites them with tools, paging older material into archival storage like an operating system paging memory to disk. It suits long-running agents that must curate their own state.

Zep, built on its open-source Graphiti engine, stores memory as a temporal knowledge graph. Its sharpest feature is that facts carry validity windows: the graph knows not just what is true, but when it was true and when it stopped being true. If your central question is fact history, nothing else is purpose-built for it. The cost is graph operations, and self-hosting needs a graph database.

Hindsight (from Vectorize) is the newest entrant: facts become observations, observations become mental models, and the agent retains, recalls, and reflects across sessions. It published the only independently reproduced results on the LongMemEval benchmark, and in November 2026 it shipped its own small decision, reranking, and embedding models for the memory pipeline.

cognee turns documents and data sources into a queryable knowledge graph, with Python, TypeScript, and Rust SDKs — closer to an ingestion pipeline than a memory API, and the natural pick when memory must be built from existing company data.

System Core idea Best for
Mem0 Memory layer API: extract facts, add/search, optional graph Production chatbots and assistants that must remember users
Letta Stateful agent runtime; the agent edits its own memory Long-running agents that manage their own context
Zep / Graphiti Temporal knowledge graph; facts with validity windows Tracking facts that change over time
Hindsight Facts → observations → mental models; retain/recall/reflect Agents that must learn and consolidate across sessions
cognee Knowledge-graph memory built from documents and data Memory grounded in existing company data sources

The decision rule: pick by what the agent needs to do with its memory, not by a leaderboard — a chatbot that must remember preferences needs a layer; an autonomous agent that runs for days needs a runtime; a support agent tracking changing facts needs a temporal graph.

How memory is measured: the benchmarks

Memory claims are easy to make and hard to check, so the benchmarks matter — and they disagree with each other in instructive ways.

LongMemEval (arXiv:2410.10813) is the most widely cited: 500 questions across long, multi-session conversations, testing whether an agent can extract, store, retrieve, and reason over information from weeks of history. LoCoMo is the long-conversation benchmark behind Mem0’s headline numbers above. “Lost in the Middle” (arXiv:2307.03172) is not a memory benchmark, but it measures the failure mode that makes short-term memory unreliable: models lose information buried in the middle of long contexts.

Read vendor benchmark claims critically. Mem0 and Zep have publicly disputed each other’s numbers, and the dispute itself is the lesson: benchmarks differ in what they reward, and a system can win one while losing another. The only reliable test is your own conversations, measured on the questions your agent actually gets wrong.

The trade-offs nobody tells you about

Memory is not free. Four trade-offs decide whether it helps or hurts.

Cost. Every retrieved memory costs tokens on every turn, and every write costs model calls in the background. A layer retrieving ten facts per turn can quietly double a chatbot’s token bill. Budget for retrieval, not just storage.

Staleness. Old facts contradict new ones, and consolidation quality decides whether the agent notices. An agent that remembers your old address after you moved is worse than one that forgot it — it is confidently wrong.

Latency. Writes are asynchronous, so they rarely slow a response — but reads happen before every reply, and a slow retrieval step adds up across millions of turns. Latency, not accuracy, is often the binding constraint.

Privacy and security. Memories accumulate the most sensitive kind of data: what users said, decided, and revealed over months. Who can read them, how a user deletes them, and how long they are kept are decisions with legal weight. Worse, memory can be attacked: the AgentPoison research (arXiv:2407.12784) showed poisoned memories in long-term storage can steer an agent’s later behaviour. We cover the full list of failure modes in our guide to the limitations of AI agent memory systems.

Sometimes the right answer is no memory at all. A single-turn tool, a stateless question-answerer, or anything handling regulated data may be better off forgetting everything — deliberately, by design.

How to choose

Work through these in order. First, does the agent actually need to remember across sessions, or is the current conversation enough? Many do not — a conversation summary carried forward is often all the “long-term memory” a product needs. Second, what must the memory do: recall user facts, track changing facts, or manage its own state? That picks the architecture — layer, temporal graph, or runtime. Third, start simple: a fact store plus a summary beats a knowledge graph on day one. Finally, measure on your own data: can the agent recall what a user said three sessions ago, notice when a fact changed, and admit it does not know? The systems differ less in their marketing than in how they fail — discover that on your test data, not your users.

What comes next

The survey’s open frontiers point to where memory research is heading: reinforcement-learning-based memory management, where agents learn what to remember from reward rather than hand-written rules; multimodal memory, covering images, audio, and video; multi-agent shared memory, where several agents read and write a common store — where memory meets A2A, the protocol for agents talking to each other; and trustworthiness, making memory auditable, deletable, and resistant to poisoning. The core idea stays the same: an agent without memory is a brilliant amnesiac; an agent with memory is a colleague.

The bottom line

Short-term memory is the current task’s working set, held in the context window and gone when the session ends. Long-term memory is the agent’s accumulated self — episodic, semantic, and procedural — stored outside the model and retrieved by meaning. The old split is a useful shorthand, but the real design questions are the survey’s three axes: form, function, and dynamics. Get those right, and the agent stops starting from zero.

Do AI agents have memory built in?

No. The language model underneath an agent is stateless — every call starts from zero. Memory is a separate layer built around the model: short-term memory in the context window, long-term memory in an external store the agent queries.

What is the difference between short-term and long-term memory in AI agents?

Short-term memory is the current task’s working set — the conversation, reasoning trace, and tool outputs inside the context window — and it disappears when the session ends. Long-term memory is stored outside the model in a vector store, graph, or database, and it persists across sessions.

Is long-term memory the same as RAG?

No, though they often share infrastructure. RAG retrieves an organisation’s reference documents; long-term memory retrieves the agent’s own accumulated history — its past conversations, decisions, and learned facts.

Which memory system should I use — Mem0, Letta, or Zep?

It depends on the job. Mem0 is a memory layer that drops into an existing agent; Letta is a stateful runtime where the agent manages its own memory; Zep is a temporal knowledge graph for facts that change over time. Pick by what the agent needs to do with its memory, not by a leaderboard.

Can an AI agent forget?

Yes — and it should. Memories decay, get summarised into higher-level facts, or are deleted when they conflict with newer information. An agent that never forgets accumulates contradictions until its answers become unreliable.

More in Artificial Intelligence

Artificial Intelligence Tier 1 · Public

A2A Protocol Explained: How AI Agents Talk to Each Other

Imagine hiring a research assistant who can only talk to people in your own office. The moment a job needs someone outside — a specialist at another company, a tool built by…

2,134 words 11 min read November 30, 2026