Skip to main content

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

typescript

Let's store conversations in MongoDB:

Storing Conversations

javascript

Retrieve recent conversation context:

Getting Conversation Context

javascript

Richmond demonstrated this when OpenAI added personality to ChatGPT. Persona memory shapes how your agent behaves.

MongoDB Document Example

Persona Memory Document

javascript

Simple persona retrieval:

Using Persona Memory

javascript

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

javascript

Find the right tool for the job:

Tool Selection

javascript

Update tool usage statistics:

Track Tool Usage

javascript

Track information about people, places, and things in your conversations.

Entity Document Pattern

Entity Memory Document

javascript

Extract and store entities from conversations:

Entity Extraction

javascript

Store entity information:

Update Entity Memory

javascript

Richmond mentioned this as storing "failure experiences" to inform future executions.

Workflow Document

Workflow Memory Document

javascript

Learn from failures:

Learning from Failures

javascript

Remember specific interactions and experiences.

Episode Document

Episodic Memory Document

javascript

Short-term, fast-access memory for recent information.

Cache Implementation

Simple Cache Memory

javascript

Now let's combine these memory types into a simple agent:

Memory-Enabled Agent

javascript

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:

  1. Conversational Memory: Store and retrieve chat history
  2. Entity Memory: Extract and remember user information
  3. Persona Memory: Give your agent a personality

Starter Code Hint

javascript

We explored 7 core memory types:

  1. Conversational Memory: Chat history and context
  2. Persona Memory: Agent personality and behavior
  3. Toolbox Memory: Available tools and their usage patterns
  4. Entity Memory: Information about people, places, and things
  5. Workflow Memory: Process states and failure lessons
  6. Episodic Memory: Specific interaction experiences
  7. 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.