AI Dev 25 | Apoorva Joshi: Building Agents That Learn—Managing Memory in AI Agents

DeepLearning.AIDeepLearning.AI
Entertainment4 min read33 min video
Mar 27, 2025|5,874 views|141|1
Save to Pod

Key Moments

TL;DR

AI agents need robust memory management for learning and collaboration. Key concepts include CRUD operations and mapping human memory types to agentic systems.

Key Insights

1

AI agents, particularly LLM-based ones, require memory to learn and act intelligently, extending beyond simple automation.

2

Human memory (short-term, long-term: semantic, episodic, procedural, working) provides a framework for understanding agentic memory.

3

Agentic memory can be mapped to concepts like conversational history (short-term), external knowledge bases (semantic), sequences of actions (episodic), and core programming/prompts (procedural).

4

Memory management for AI agents involves CRUD operations: creating, retrieving, updating, and deleting memories efficiently.

5

Persisting memories in external databases is crucial for long-term retention and retrieval, with effective modeling for timely access.

6

Retrieval techniques, adapted from search and RAG, like exact matching, vector search, and hybrid search, are essential for accessing relevant memories.

THE EVOLUTION OF AI AGENTS AND THE NEED FOR MEMORY

AI agents have evolved significantly from their '90s reinforcement learning origins to sophisticated LLM-based systems. While early agents focused on maximizing rewards through predefined actions, modern agents leverage LLMs for reasoning, planning, and tool execution. This evolution necessitates advanced capabilities beyond simple task automation, moving towards systems that can adapt, personalize, and learn. A critical, yet often overlooked, component enabling this intelligence is memory, which allows agents to retain knowledge and learn from past experiences, thereby fostering trust and reliability for future collaborations.

MAPPING HUMAN MEMORY TO AGENTIC SYSTEMS

Understanding human memory provides a valuable blueprint for developing memory systems in AI agents. Humans possess short-term memory for immediate information and working memory for active processing, but it's long-term memory—semantic, episodic, procedural, and sensory—that underpins intelligence. Semantic memory stores facts, episodic memory recalls life events, procedural memory governs 'how-to' skills, and sensory memory retains stimuli. Translating these concepts into software allows AI agents to develop analogous capabilities, moving them closer to human-like cognitive functions and intelligent behavior.

TYPES OF MEMORY IN AI AGENTS

In AI agents, short-term memory often manifests as recent conversational history, crucial for maintaining context. Long-term memory is more complex. Semantic memory can be augmented through external knowledge bases like databases, supplementing the inherent knowledge encoded in LLM weights. Episodic memory translates to sequences of actions an agent takes to complete tasks, logged for later reference. Procedural memory is partly in the LLM's weights, but also influenced by the agent's code and adaptable system prompts. Working memory is the context window, holding current task information, tool outcomes, and retrieved memories.

MASTERING MEMORY MANAGEMENT: CRUD OPERATIONS

Effective memory management for AI agents relies on fundamental CRUD operations: Create, Retrieve, Update, and Delete. Creating memories involves extracting insights from LLM reasoning traces, tool outcomes, user interactions, or environmental feedback, rather than just storing raw data. Persisting these memories in external databases is vital for long-term availability. Retrieval methods, including exact matching, vector search, and hybrid approaches, efficiently access relevant information. Updating memories incorporates new data, while deleting or phasing out old, unused memories optimizes performance and prevents unbounded growth.

STRATEGIES FOR MEMORY CREATION AND PERSISTENCE

Creating memories requires agents to synthesize information, focusing on extracting specific insights rather than logging every detail. This synthesis can be triggered by various events, such as new inputs, a near-full context window, or at the end of conversations. Persistence is key; memories must be stored externally to be accessible across sessions. Modeling memories with temporal aspects (creation/update timestamps) aids in filtering, prioritization, and phasing out. For procedural memories like system prompts, maintaining a single, updatable source of truth is beneficial, although periodic reconciliation may be needed to manage data growth.

EFFICIENT MEMORY RETRIEVAL AND UPDATING

Retrieving memories is crucial for informed decision-making, with timing depending on the agent's task—before every action in simulations, during initial planning for task execution, or only when errors occur in code generation. Techniques like exact matching, vector search (which leverages embeddings for meaning-based retrieval), and hybrid search (combining keyword and vector approaches) are employed. Furthermore, retrieved memories can be re-scored and re-ranked based on recency, importance, or custom criteria, like prioritizing recent events or weighting significant memories higher. Updating memories involves retrieving relevant stored data, integrating new information, and persisting the revised memory.

THE NECESSITY OF DELETING AND THE TAKEAWAYS

Deleting or phasing out memories is as important as creating them. While storage is inexpensive, enterprise-grade access incurs costs, and storing unused data is wasteful. Efficient retrieval depends on a manageable search space. This is achieved by implementing data lifecycle policies, monitoring usage, moving data to archival storage, and imposing retention periods to delete old memories. Key takeaways emphasize that memory definition varies by application, not all memories are equal in management, comprehensive storage is impractical, and long-term memory management is fundamental for advancing AI agents towards AGI, whether embedded in LLM weights or through external systems.

AI Agent Memory Management Cheat Sheet

Practical takeaways from this episode

Do This

Create meaningful summaries of raw data for long-term memory.
Persist memories in an external database for future use.
Use timestamps to manage memory recency and aging.
Employ techniques like vector or hybrid search for efficient retrieval.
Rescore and rerank memories based on recency and importance.
Update memories by retrieving, reconciling, and re-storing new information.
Implement data lifecycle policies for managing memory deletion.

Avoid This

Store every raw detail of past experiences; extract key insights instead.
Rely solely on the LLM's context window for memory persistence.
Neglect memory management, which can lead to agent unreliability or hallucinations.
Allow unbounded memory growth without periodic reconciliation or deletion.
Treat all memories as equally important; prioritize based on recency and significance.

Common Questions

In the generative AI era, AI agents are typically LLM-based systems that can reason through problems, create plans, execute them using tools, and iterate based on feedback and past interactions, aiming for a form of autonomy.

Topics

Mentioned in this video

conceptShort-term memory

Human memory used for recent conversations and observations, analogous to chat history in LLMs.

conceptWorking memory

A type of short-term memory that temporarily stores information the brain is actively working on, like intermediate calculations in a math problem. In AI agents, this is the context window.

conceptLong-term memory

Human memory for recalling and learning from extended experiences, crucial for intelligence. This is the focus for AI agent memory management.

softwareVector Databases

Mentioned as a type of tool that LLM-based AI agents can use for actions and memory.

conceptCRUD

A common acronym for database operations (Create, Read, Update, Delete), used by the speaker as an analogy for managing AI agent memories.

personJohn Lynn

A character in a Sims example used to illustrate episodic memory scoring and retrieval.

toolHybrid search

A search method combining keyword-based and vector-based approaches, useful for prioritizing relevant memories.

conceptEpisodic memory

Memory of past events and life episodes. In agents, this translates to sequences of actions taken to complete tasks.

conceptProcedural memory

Memory of how to do things (skills). In agents, this is encoded in LLM weights and agent code, and can be updated via prompts.

conceptReinforcement Learning agents

The original idea of AI agents, which learn by maximizing rewards based on environmental feedback.

conceptSemantic memory

Long-term store of knowledge (facts, learned information). In agents, this can be supplemented by external databases.

conceptSensory memory

Memories from sensory stimuli (smell, taste, sound). The speaker believes AI agents are currently far from processing these.

conceptVector Search
toolMongoDB

More from DeepLearningAI

View all 65 summaries

Found this useful? Build your knowledge library

Get AI-powered summaries of any YouTube video, podcast, or article in seconds. Save them to your personal pods and access them anytime.

Try Summify free