AI Agent Memory Stack Organizes Around Building Blocks, Patterns, and Frameworks

AI Agent Memory Stack Organizes Around Building Blocks, Patterns, and Frameworks
3 min read

A language model does not retain information from one call to the next: with each execution, it only works with the text provided in the request. For AI agents, which need to track their past actions, remember a user’s preferences, or pursue a multi-step task, this limitation makes an external memory necessary. This memory stores information outside the model’s context window, i.e., the amount of text a model can process at once, and retrieves it when useful.

The Building Blocks of Agent Memory

Agents need to carry information from one call and task to another. They may need to remember what has already been planned to avoid duplicate actions, or keep track of failed attempts to avoid repeating the same work. Without memory, each call only has the context provided to it.

Types of memory fall into four categories. Working memory holds the active state of the task, such as intermediate results, and is accessed directly by key. Episodic memory retains what has happened: past interactions, task executions, and decisions made, in a chronological log or a vector database, with search by semantic similarity. Semantic memory gathers what is held to be true, namely facts and preferences, which are updated rather than added. Procedural memory describes how to do things, whether successful action patterns or known failure modes, and relies on prompt templates or fine-tuning, an adjustment of the model based on specific data.

Designing Reliable Memory

In the example of a research agent working on the same task over several days, each result is first written to working memory with a short lifespan. When a result proves useful, it moves to episodic memory with an importance score. Before each tool call, the agent consults working memory and then, if needed, episodic memory. If the task fails midway, the temporary state can be erased while the history of completed work is preserved.

Several practices make memory more reliable as it grows: noting the importance of information before writing it, limiting each agent’s memory to its role in multi-agent systems, consulting memory at each decision step, and tracing the origin of each item, whether it comes from an agent, a tool, user input, or a timestamp. Some approaches, simple to implement, become unreliable instead. This is the case of storing everything in a single vector database, compression by free-form summaries which can erase numbers or constraints, unlimited memory growth, or trusting each write equally. The latter exposes to memory poisoning, where unreliable or malicious content is stored and then treated as safe information.

Frameworks with Different Approaches

Frameworks sit between simple textual memory and knowledge graphs. Letta relies on text blocks that the agent can rewrite itself, and updates a block when it detects a contradiction. Mem0 uses a vector memory with entity-aware search, and adds new memories alongside old ones. Graphiti is based on a bi-temporal knowledge graph with typed relationships: it invalidates old relationships while keeping their history searchable. Cognee builds graph, vector, and relational layers from source data, and reconstructs the memory representation, with temporal modes to track changes.

In multi-agent systems, memory sharing can cause conflicts during simultaneous updates. Proposed solutions include a central service with write control, separate namespaces for each agent, or append-only logs where conflicts are resolved at search time. Evaluation relies on several metrics: recall, which measures if relevant memories are retrieved, precision, which measures the proportion of useless information returned, fidelity, which checks the correct usage of retrieved information, and staleness, which measures the frequency of outdated information. According to the article, the choice depends on the agent’s workload, its data, and its operational requirements.