Agent Memory
Mechanisms that allow AI agents to retain and recall information across interactions, enabling continuity and context-aware behaviour over time.
Agent memory refers to the systems and techniques that allow an AI agent to store, organise, and retrieve information across interactions. Without memory, an agent starts every conversation from scratch β with memory, it can build on previous work, remember user preferences, and maintain project context.
Types of agent memory
Agent memory is typically divided into several categories:
- Short-term memory (working memory): The current conversation or task context. This is essentially the context window β the text the model can "see" right now. It is fast and precise but limited in size and lost when the session ends.
- Long-term memory: Information persisted between sessions β user preferences, project history, learned facts, and accumulated knowledge. This is typically stored in external databases or files and retrieved when relevant.
- Episodic memory: Records of specific past interactions or events. "Last Tuesday, the user asked me to refactor the authentication module and preferred using JWT tokens."
- Semantic memory: General knowledge the agent has accumulated. "This codebase uses TypeScript with the Next.js App Router pattern."
How memory is implemented
- Context window stuffing: Injecting relevant past information into the current prompt. Simple but limited by context window size.
- Vector databases: Storing memories as embeddings and retrieving the most relevant ones via similarity search. Scales well but can miss important context.
- Structured files: Using markdown or JSON files (like progress files or CLAUDE.md) to maintain structured project state that the agent reads at the start of each session.
- Database storage: Relational or key-value stores for precise, queryable memory β user profiles, task history, configuration.
Challenges with agent memory
Memory management introduces difficult trade-offs. Storing everything creates noise and makes retrieval unreliable. Being too selective risks losing important context. Memory also needs maintenance β outdated information can cause incorrect behaviour. Strategies like memory summarisation, decay, and explicit refresh help manage these issues.
Practical patterns
The most effective approach for most business applications combines a structured progress file for project state, a vector store for searchable knowledge, and explicit user preference storage for personalisation.
Why This Matters
Agent memory is what separates a useful AI assistant from one that frustrates users by forgetting everything between sessions. Understanding memory architectures helps you design AI workflows that maintain continuity and improve over time.
Related Terms
Continue learning in Advanced
This topic is covered in our lesson: Building Your Own AI Solutions