Memory Types & Architecture
Master 10+ different types of agent memory and learn how to architect comprehensive memory systems
Introduction
Memory Types and Architecture
Now that we understand why memory matters, let's explore the different types of memory that make agents truly intelligent. We'll implement each type with simple, practical examples—just like Richmond Alake demonstrated in his MongoDB talk.
Richmond showed us that agents need different types of memory, just like humans:
graph TB subgraph "Human Memory Types" A[Short-term Memory] B[Long-term Memory] C[Working Memory] D[Episodic Memory] E[Semantic Memory] F[Procedural Memory] end subgraph "Agent Memory Types" G[Conversational Memory] H[Entity Memory] I[Persona Memory] J[Toolbox Memory] K[Workflow Memory] L[Episodic Memory] M[Cache Memory] end A -.-> G B -.-> H C -.-> I D -.-> L E -.-> H F -.-> J
MongoDB as Memory Provider
"MongoDB is the memory provider for agentic systems" - Richmond Alake. The flexible document model can adapt to any memory structure you need.
The most basic type—remembering what was said.
Simple Implementation
Basic Conversation Memory
Let's store conversations in MongoDB:
Storing Conversations
Retrieve recent conversation context:
Getting Conversation Context
Richmond demonstrated this when OpenAI added personality to ChatGPT. Persona memory shapes how your agent behaves.
MongoDB Document Example
Persona Memory Document
Simple persona retrieval:
Using Persona Memory
Richmond explained: "When you use your database as a toolbox where you're storing the JSON schema of your tools in MongoDB, you can scale."
Tool Storage Pattern
Toolbox Memory Document
Find the right tool for the job:
Tool Selection
Update tool usage statistics:
Track Tool Usage
Track information about people, places, and things in your conversations.
Entity Document Pattern
Entity Memory Document
Extract and store entities from conversations:
Entity Extraction
Store entity information:
Update Entity Memory
Richmond mentioned this as storing "failure experiences" to inform future executions.
Workflow Document
Workflow Memory Document
Learn from failures:
Learning from Failures
Remember specific interactions and experiences.
Episode Document
Episodic Memory Document
Short-term, fast-access memory for recent information.
Cache Implementation
Simple Cache Memory
Now let's combine these memory types into a simple agent:
Memory-Enabled Agent
1. According to Richmond Alake, what makes MongoDB ideal for agent memory?
- A)It's faster than other databases
- B)The flexible document model can adapt to any memory structure
- C)It has built-in AI capabilities
- D)It's cheaper than other solutions
Show Answer
Correct Answer: B
Richmond emphasized that MongoDB's flexible document model can adapt to any memory structure, making it perfect as a memory provider for agentic systems.
2. What is the main advantage of toolbox memory over putting all tools in the context window?
- A)Tools run faster
- B)Tools are more secure
- C)You can scale beyond the LLM's context limit
- D)Tools are easier to debug
Show Answer
Correct Answer: C
Richmond explained that storing tools in a database allows you to scale beyond the LLM's context window limits by retrieving only relevant tools as needed.
3. Why is workflow memory important for agent reliability?
- A)It makes workflows run faster
- B)It allows agents to learn from failures and avoid repeating mistakes
- C)It reduces memory usage
- D)It improves security
Show Answer
Correct Answer: B
Workflow memory captures failure experiences so agents can learn from past mistakes and make better decisions in future executions.
Create a simple agent that uses multiple memory types:
- Conversational Memory: Store and retrieve chat history
- Entity Memory: Extract and remember user information
- Persona Memory: Give your agent a personality
Starter Code Hint
We explored 7 core memory types:
- Conversational Memory: Chat history and context
- Persona Memory: Agent personality and behavior
- Toolbox Memory: Available tools and their usage patterns
- Entity Memory: Information about people, places, and things
- Workflow Memory: Process states and failure lessons
- Episodic Memory: Specific interaction experiences
- Cache Memory: Fast-access temporary storage
MongoDB Document Flexibility
Each memory type maps naturally to MongoDB documents, giving you the flexibility to store any structure while maintaining powerful query capabilities.
In the next module, we'll build a unified memory management system that coordinates all these memory types, handling storage, retrieval, and memory lifecycle management.
Memory is the Foundation
These memory types form the foundation of intelligent agents. In production systems, they work together to create agents that are truly believable, capable, and reliable.