Agent Memory Explained: Short-Term, Long-Term, Files
Language models are stateless: each call starts from nothing. Everything an agent "remembers" is something your system chose to put back in front of it.
- Published
Four kinds of memory
| Type | What it holds | Lifetime |
|---|---|---|
| Context window | The current conversation and working data | One session |
| Summaries | Compressed history of long conversations | Session or across sessions |
| Long-term store | Facts and preferences about a user or account | Persistent |
| Files / scratchpad | Notes, plans and intermediate results the agent writes | Task or project |
Design choices
- Summarise long conversations instead of re-sending everything — it is cheaper and often more accurate.
- Store facts as structured records (preferred language, account tier) rather than free text where you can.
- Let long-running agents write plans and progress to files, so work survives restarts.
- Retrieve memories by relevance, not all at once.
Privacy rules
- Tell users what is remembered and let them delete it.
- Never store secrets or payment data in agent memory.
- Scope memory per user or account — never share across customers.
- Set retention periods and enforce them.
Frequently asked questions
Does the model learn from conversations?
Not by itself. Memory is data your system stores and re-supplies; the model weights do not change.
Why does my agent forget in long chats?
The context fills up or older turns get truncated. Summaries and structured memory fix it.
Is long-term memory always useful?
Not always. For one-off support queries it adds little; for account managers and assistants it adds a lot.