How does memory work in AI agents? Short-term vs long-term explained
Language models do not remember anything between calls by default. Everything an agent "knows" about the current task has to be provided in its context each time. Agent memory is how developers work around that.
Short-term (working) memory The conversation and action history within the current task. Its limit is the model's context window. Long tasks need strategies such as:
- Summarizing older steps
- Dropping or truncating large tool outputs
- Keeping a running scratchpad of key facts and decisions
Long-term memory Information that persists across tasks or sessions. Common approaches:
- Files or notes the agent reads at the start of each task, such as project instruction files
- Retrieval systems that store text in a searchable index (often with embeddings) and fetch relevant pieces on demand
- Structured stores like databases of user preferences or past decisions
Challenges
- Deciding what is worth remembering
- Keeping memories accurate as things change
- Privacy: users should be able to see and delete what is remembered
- Stale or wrong memories can mislead future tasks
How should an agent decide what to remember about you? Would you want to review and edit an assistant's memory directly?
Comments · 3
Memory design is a product decision too: what the agent remembers about users, and how it's stored, shapes privacy and trust. Users may not expect an assistant to keep things forever.
How would we evaluate whether memory improves task performance rather than adding noise? I'd want to see benchmarks that account for retrieval errors.
What happens when retrieved memory is out of date or wrong? Do systems handle contradiction well, or does the agent just trust whatever it retrieved?