Architecting Agent Memory: Principles, Patterns, and Best Practices

Richmond Alake, MongoDB17:37 · Jun 2025 · 135K views
Thumbnail for Architecting Agent Memory: Principles, Patterns, and Best Practices Watch on YouTube
TL;DR
  1. 1

    Memory gives agents persistent state that can inform later execution steps.

  2. 2

    Agent memory includes different forms such as persona, toolbox, conversation, workflow, episodic, and entity memory.

  3. 3

    Effective memory management retrieves and structures relevant information instead of filling the context window with all available data.

Summary

Richmond Alake argues that memory is a core part of an AI agent because it lets the system retain information, use past experience, and inform its next action. He frames memory management as a lifecycle covering generation, storage, retrieval, integration, updating, and forgetting. The talk introduces several memory types, including persona memory for relationships with users, toolbox memory for selecting tools, conversation memory for chat history, and workflow memory for recording failed execution paths. Alake presents MongoDB as a flexible storage and retrieval layer for these patterns, with vector, text, graph, geospatial, and query capabilities. He also discusses Memoriz, his experimental open-source library, and MongoDB's acquisition of Voyage AI. The practical message is that large context windows do not remove the need for selection and structure. Agents need systems that retrieve useful memories at the right time and keep irrelevant information out of the prompt.

Key ideas
02:59

An agent needs memory to retain state and improve later actions

Alake defines an AI agent as a computational entity that perceives its environment, uses an LLM for cognitive abilities, and takes action through tools. He adds that an agent also needs some form of short-term or long-term memory. Memory lets agents become reflective, interactive, proactive, reactive, and autonomous. In his definition, agent memory is the mechanism that makes state persist in an AI application. The agent accumulates information, turns data into memory, and uses it to inform the next execution step. The intended result is an agent that is more reliable, believable, and capable.

06:06

Memory management selects and structures context across a full lifecycle

Alake describes memory management as the systematic process of organizing information that enters the context window. A large context window should not be treated as a place to put every piece of data. The system should retrieve relevant memory and structure it so the model can produce a relevant response. He lists generation, storage, retrieval, integration, updating, and deletion as the main parts of the lifecycle. He questions literal deletion and suggests that agent systems need forgetting mechanisms instead. Retrieval is especially important because the system must decide which stored information belongs in the next model call.

09:27

Different memory types support different agent behaviors

The talk presents several ways to model memory. Persona memory gives an agent a consistent personality and helps it build relationships with users. Toolbox memory stores tool JSON schemas so the system can search for the relevant tool shortly before calling the LLM, instead of placing every tool in the prompt. Conversation memory stores exchanges with fields such as timestamps and conversation IDs. Workflow memory records execution steps and failures. A failed step can become experience that the system retrieves during a later run, telling the LLM to avoid that path or explore another one. Alake also mentions episodic, long-term, entity, and agent-registry memory.

12:35

A database can provide storage and retrieval for custom memory systems

Alake presents MongoDB as a memory provider for agentic systems. He says its document model can adapt to different data structures and that it combines graph, vector, text, geospatial, and ordinary query capabilities. He also mentions Memoriz, an experimental and educational open-source library containing memory implementations and design patterns. Alake names MemGPT, Mem0, and Zep as tools focused on memory management, but says there is no single way to solve memory. His conclusion is that developers need a provider that supports custom memory-management systems rather than assuming one fixed design.

13:33

Embedding and reranking services can reduce retrieval problems in agent systems

Alake says MongoDB acquired Voyage AI earlier in the year. He describes Voyage AI as providing embedding models, a text multimodal model, and rerankers. These components are intended to help with retrieval and reduce hallucination in RAG and agentic systems. He says MongoDB plans to bring Voyage AI embedding models and rerankers into MongoDB Atlas in the following months. He also describes a goal of reducing the work developers must do around data management, chunking, and retrieval strategies by bringing more of that process into the database.

15:28

Research on human memory and perception can inform agent design

Alake closes by connecting agent memory to neuroscience. He discusses research by David Hubel and Torsten Wiesel on the visual cortex of cats, which found that visual processing learns hierarchies of representation such as edges, contours, and abstract shapes. He links this work to convolutional neural networks used for face and object detection. Alake says nature provides a useful model for building intelligent systems. He describes a meeting involving MongoDB's chief AI scientist Tenu, neuroscientists, and Charles Packer, the creator of MemGPT, as an example of people from these fields discussing memory and the path toward AGI.

"You don't want to delete memories. We really should be looking at implementing forgetting mechanisms within the memory management systems that we're building."07:14
Who should watch
  • You are building an agent that needs to remember conversations, user preferences, tools, or previous workflow failures.
  • Your system has a large context window, but retrieval quality and prompt size are becoming difficult to control.
  • You are designing a custom memory layer for a RAG, autonomous-agent, or multi-agent application.