Skip to main content

Memory Storage

To persist memories across sessions and execution cycles, store memories in a persistent storage like a database. If you’re using Memory in production, persistent storage is critical as you’d want to retain user memories across application restarts. Agno’s memory system supports multiple persistent storage options.

Storage Options

The Memory class supports different backend storage options through a pluggable database interface. Currently, Agno provides:
  1. SQLite Storage
  2. PostgreSQL Storage
  3. MongoDB Storage
  4. Redis Storage

Setting Up Storage

To configure memory storage, you’ll need to create a database instance and pass it to the Memory constructor:

Data Model

When using persistent storage, the Memory system stores:
  • User Memories - Facts and insights about users
  • Last Updated Timestamps - To track when memories were last modified
  • Memory IDs - Unique identifiers for each memory

Storage Examples

sqlite_memory.py
postgres_memory.py

Integrating with Agent Storage

When building agents with memory, you’ll often want to store both agent sessions and memories. Agno makes this easy by allowing you to configure both storage systems:

Memory Management

When using persistent storage, the Memory system offers several functions to manage stored memories:

Developer Resources

  • Find reference documentation for memory storage here