Short-term vs long-term agent memory
Short-term memory in an AI agent is the state of the current conversation or task, held in the context window and scoped to one thread. Long-term memory is what the agent keeps in a separate store and reads back in later sessions, usually split into episodic, semantic and procedural memory. Most useful agents need both, and customer-facing agents also need a third input neither covers, the user's live behavior.
Short-term vs long-term memory in AI agents comes down to scope. Short-term memory is the state of the conversation or task in progress, held in the context window and scoped to one thread. Long-term memory is what the agent saves to a separate store and reads back in a later session, such as a fact about the user or a record of how a past problem was solved.
This page covers how the main agent frameworks draw that line, how each memory type is written and recalled, and the input most of them leave out. For what agent memory is in general and how tools such as Mem0, Zep and Letta compare, start with what is agent memory.
What is short-term memory in an AI agent?
Short-term memory is everything the agent needs to stay coherent inside one task: the messages so far, the results of the tools it called, the plan it is following. The CoALA paper (Sumers, Yao, Narasimhan and Griffiths) calls this working memory, which “maintains active and readily available information” for the current decision cycle.
In practice, short-term does not have to mean volatile. LangGraph’s memory docs define short-term memory as what “lets your application remember previous interactions within a single thread or conversation”, and persist it with a checkpointer so a thread can be resumed later. What makes it short-term is the scope. It belongs to one thread, and a new thread starts empty.
Its limit is size. Every message and tool result takes room in the context window, so a long task either outgrows the window or fills it with turns that no longer matter. Frameworks handle this by trimming old messages or summarizing them, which is one of the jobs of context engineering.
What is long-term memory in an AI agent?
Long-term memory outlives the thread. LangGraph keeps it as JSON documents in a store, each filed under a namespace such as a user id, so any later conversation with that user can search it. Most frameworks split it the way CoALA does, into three kinds:
- Episodic memory stores “experience from earlier decision cycles”: what happened in a past session and how it ended.
- Semantic memory stores knowledge about the world and the user: the plan they are on, the language they write code in.
- Procedural memory is how the agent does its job. CoALA places it in the model’s weights and the agent’s code. LangGraph’s example is the system prompt, which an agent can refine over time.
The MemGPT paper, the research behind Letta, frames the split as an operating system would: fast memory in the context window, slow memory outside it, and the agent moves data between the two. In Letta the fast tier is memory blocks “pinned to the system prompt” that the agent edits through memory tools, and old messages stay retrievable after they leave the window.
How do the memory types compare?
The first four rows are the types the frameworks above define. The last row is the one they mostly leave out, covered in the next section.
| Memory type | Where it is stored | How long it lasts | How it is written | How it is recalled | How it fails |
|---|---|---|---|---|---|
| Working (short-term) | The context window, checkpointed per thread | One thread or task | Appended as the conversation and tool calls happen | Always in the prompt | Overflows the window, or drops early turns that mattered |
| Episodic | A long-term store, by user or agent | Across sessions, until deleted | Saved after a session, often as a summary | Searched by similarity to the current question | Recalls a past case that looks similar but is not |
| Semantic | A long-term store, as facts or a profile | Across sessions, until overwritten | Extracted from what the user said, in the conversation or in the background | Pinned as a profile, or searched | Keeps a fact the user has since changed |
| Procedural | The system prompt, agent code or model weights | Until someone edits it | Written by the developer, sometimes refined by the agent | Always loaded | A refined rule drifts from what the developer intended |
| Behavioral state | A store computed from product events, by session or user | Rolling: this session, or a window such as seven days | Computed from events as the user acts | Read at the moment the agent responds | Missing when the product does not record the action |
What do short-term and long-term memory both miss?
Both are built from text. Short-term memory is what was said in this thread. Long-term memory is what was extracted from earlier threads and the documents you loaded. Neither contains what the user did in your product and never typed: the export that failed three times, the pricing page they opened before they asked, the setting they changed and changed back.
Call that behavioral state. It is a third axis rather than a third timescale, and it differs from both kinds of memory in two ways:
- Its source is events, not conversation. It is computed from what your product records, so it holds things the user would not think to mention.
- It changes faster than long-term memory. A semantic fact like “on the Team plan” might change once a year. “Failed exports this session” changes between one message and the next, and it is out of date the moment it is cached for tomorrow. The case for reading it fresh is in why AI agents need real-time context.
It is also not a fifth entry in the long-term store. Saving “had export trouble on Tuesday” as an episodic memory is reasonable after the fact. The live count belongs to the current moment, and the agent should read it, not remember it.
Example: one support session, five kinds of memory
A data analyst uses a reporting app on a Team plan. They open the in-app chat and type “why won’t my report export?” Here is what the support agent has to work with, by type.
- Working memory. That one message, plus the result of the account lookup the agent calls first.
- Episodic memory. A session three weeks ago where a large export timed out, resolved by splitting it by date range.
- Semantic memory. The user is an admin on the Team plan and asked last time for answers with code samples in Python.
- Procedural memory. The system prompt: explain limits plainly, never promise a plan change, hand over to a person if data may be lost.
- Behavioral state. In this session the export failed three times, the last time with a row-limit error, and the user opened the pricing page in between.
The first four tell the agent who this is and how to behave. Only the last tells it what went wrong today, and it points away from the episodic match: this is a row limit, not a timeout. Without it, the agent suggests the date-range fix that worked last time.
The behavioral part is defined as attributes, values computed from events about one key, here the session. This definition counts failed exports and keeps the last error code:
from snowplow_signals import (
Attribute, Event, EventProperty, StreamAttributeGroup, domain_sessionid,
)
export_failed = Event(name="export_failed", vendor="com.example", version="1-0-0")
exports_failed_session = Attribute(
name="exports_failed_session",
type="int32",
events=[export_failed],
aggregation="counter",
default_value=0,
)
last_export_error = Attribute(
name="last_export_error",
type="string",
events=[export_failed],
aggregation="last",
property=EventProperty(vendor="com.example", name="export_failed", major_version=1, path="error_code"),
)
app_support_exports = StreamAttributeGroup(
name="app_support_exports",
version=1,
attribute_key=domain_sessionid,
owner="you@example.com",
attributes=[exports_failed_session, last_export_error],
)
When the chat opens, the agent’s code reads the group for this session and gets values such
as exports_failed_session: 3 and last_export_error: "row_limit". Those go into the prompt
beside the recalled memories, and the model decides what to say.
Where Signals fits
Short-term memory comes with the agent framework, and long-term memory from a recall tool or a store you run. For behavioral state you need an event stream and something that computes and serves values from it while the session is open. You can build that yourself. Snowplow Signals is one option: it collects behavioral events, computes attributes like the ones above, and serves them, or the customer’s recent activity as JSON or a short narrative, through an SDK, a REST API or an MCP server. It runs beside the memory tool you already use and does not replace it. The rest of the AI agents and memory topic covers the other parts of an agent’s context.
See it on your own traffic
Add the SDK, define one attribute, and see an attribute updating against your own traffic in the first session. The free tier runs on the real engine: no card, no sales call.