Skip to main content
Memory in Marvin allows agents to store and recall information across multiple conversations and sessions. Unlike threads, which maintain context within a single interaction, memory provides long-term persistence that survives across program restarts.

What is Memory?

A Memory in Marvin is a specialized module that:
  1. Stores information in a vector database for efficient retrieval
  2. Allows agents to remember facts, preferences, and knowledge
  3. Can be shared between different agents or kept private
  4. Persists across multiple conversations and program executions

Memory vs. Thread

It’s important to understand the difference between Memory and Thread:

Creating and Using Memory

Basic Memory Creation

To create a memory module:
The parameters are:
  • key: A unique identifier for this memory (alphanumeric and underscores only)
  • instructions: Guidance for how the memory should be used

Attaching Memory to Agents

Memory modules are attached to agents:

Sharing Memory Between Agents

Multiple agents can share the same memory:

Memory Operations

Adding Information

Memory is typically populated through agent interactions, but you can also add information programmatically:

Searching Memory

You can search memory directly:

Deleting Memory

To remove specific memories:

Memory Configuration

Memory Providers

Marvin uses a memory provider to handle the storage and retrieval of memories. By default, it uses a SQLite-based provider, but you can configure others:

Auto-Use Memory

You can configure a memory to be automatically used before each agent interaction:

Best Practices

  • Specific Instructions: Provide clear instructions about what should be stored in each memory
  • Descriptive Keys: Use meaningful keys that describe the memory’s purpose
  • Memory Separation: Create separate memories for different types of information
  • Selective Storage: Don’t store everything - focus on important information that needs to be remembered
  • Regular Maintenance: Periodically review and clean up memories that are no longer needed

Advanced Usage

Multiple Memory Modules

Agents can have multiple memory modules for different purposes:

Memory in Teams

Memory can be shared across a team of agents:
Memory is a powerful feature that enables more personalized, context-aware AI applications. By effectively using memory, your agents can build up knowledge over time and provide more consistent, informed responses.