Agent memory
How an AI agent keeps information beyond one conversation: notes, facts and preferences it saves and reads back later.
Agent memory is how an AI agent keeps information beyond one conversation: facts, preferences and notes it saves and reads back in later sessions. Without it every session starts from zero; with it the agent can recall a customer’s setup or a decision made last week.
Short-term memory is the current conversation in the context window. Long-term memory is a store, often files or a database the agent writes to and searches, that survives across sessions; reading from it works much like RAG. The hard parts are deciding what is worth keeping, correcting memories that turn out wrong, and keeping one user’s memory away from another. A wrong memory is worse than none, because the agent repeats it with confidence. Memories about people are also personal data, so the usual rights to access and erasure apply.
Memory differs from compaction, which shortens the current session, and from project files such as AGENTS.md, which people write and review. A stored memory can also carry an instruction planted in a document the agent once read, so the prompt injection risk outlives the session.
Related terms
- Context engineering: Deciding what goes into the model’s context, in what order and when, across a whole task.
- Compaction: Replacing the older part of a long conversation with a summary so the agent can keep going.
- RAG (retrieval-augmented generation): Finding relevant documents first and putting them into the prompt, so the model answers from them.
- AGENTS.md and CLAUDE.md: Files in a repository with the rules a coding agent reads at the start of every session.
- Prompt injection: Instructions hidden in data (a web page, an email, a file) that the model follows as if they came from you.
- Context window: The maximum number of tokens the model can read and write in one request.
