How Memory Works
When relevant information appears in a conversation, like a user’s name, preferences, or habits, an Agent with Memory automatically stores it in your database. Later, when that information becomes relevant again, the agent retrieves and uses it naturally in the conversation. The agent is effectively learning about each user across interactions.Memory ≠ Session History: Memory stores learned user facts (“Sarah prefers email”), session history stores conversation messages for continuity (“what did we just discuss?”).
Getting Started with Memory
Setting up memory is straightforward: just connect a database and enable the memory feature. Here’s a basic setup:enable_user_memories=True
, your agent automatically creates and updates memories after each conversation. It extracts relevant information, stores it, and recalls it when needed, with no manual intervention required.
Two Approaches: Automatic vs Agentic Memory
Agno gives you two ways to manage memories, depending on how much control you want the agent to have:Automatic Memory (enable_user_memories=True
)
Memories are automatically created and updated after each agent run. Agno handles the extraction, storage, and retrieval behind the scenes. This is the recommended approach for most use cases. It’s reliable and predictable.
Agentic Memory (enable_agentic_memory=True
)
The agent gets full control over memory management through built-in tools. It decides when to create, update, or delete memories based on the conversation context.
Important: Don’t enable both
enable_user_memories
and enable_agentic_memory
at the same time, as they’re mutually exclusive. While nothing will break if you set both, enable_agentic_memory
will always take precedence and enable_user_memories
will be ignored.Storage: Where Memories Live
Memories are stored in the database you connect to your agent. Agno supports all major database systems: Postgres, SQLite, MongoDB, and more. Check the Storage documentation for the full list of supported databases and setup instructions. By default, memories are stored in theagno_memories
table (or collection, for document databases). If this table doesn’t exist when your agent first tries to store a memory, Agno creates it automatically with no manual schema setup required.
Custom Table Names
You can specify a custom table name for storing memories:Manual Memory Retrieval
While memories are automatically recalled during conversations, you can also manually retrieve them using theget_user_memories
method. This is useful for debugging, displaying user profiles, or building custom memory interfaces:
Memory Data Model
Each memory stored in your database contains the following fields:Field | Type | Description |
---|---|---|
memory_id | str | The unique identifier for the memory. |
memory | str | The memory content, stored as a string. |
topics | list | The topics of the memory. |
input | str | The input that generated the memory. |
user_id | str | The user ID of the memory. |
agent_id | str | The agent ID of the memory. |
team_id | str | The team ID of the memory. |
updated_at | int | The timestamp when the memory was last updated. |
View and manage all your memories visually through the Memories page in AgentOS/