User Memories
When we speak about Memory, the commonly agreed upon understanding of Memory is the ability to store insights and facts about the user the Agent is interacting with. In short, build a persona of the user, learn about their preferences and use that to personalize the Agent’s response.
Agentic Memory
Agno Agents natively support Agentic Memory Management and recommends it as the starting point for your memory journey.
With Agentic Memory, The Agent itself creates, updates and deletes memories from user conversations.
Set enable_agentic_memory=True
to give the Agent a tool to manage memories of the user, this tool passes the task to the MemoryManager
class.
You may also set
enable_user_memories=True
which always runs theMemoryManager
after each user message. See below for an example.
add_history_to_messages=True
adds the chat history to the messages sent to the Model, thenum_history_runs
determines how many runs to add.read_chat_history=True
adds a tool to the Agent that allows it to read chat history, as it may be larger than what’s included in thenum_history_runs
.
Creating Memories after each run
While enable_agentic_memory=True
gives the Agent a tool to manage memories of the user, we can also always “trigger” the MemoryManagement
after each user message.
Set enable_user_memories=True
which always process memories after each user message.
Memory Management
The Memory
class in Agno lets you manage all aspects of user memory. Let’s start with some examples of using Memory
outside of Agents. We will:
- Add, update and delete memories
- Store memories in a database
- Create memories from conversations
- Search over memories
Adding a new memory
Updating a memory
Deleting a memory
Creating memories from user information
Creating memories from a conversation
Memory Search
Agno provides several retrieval methods to search and retrieve user memories:
Basic Retrieval Methods
You can retrieve memories using chronological methods such as last_n
(most recent) or first_n
(oldest first):
Agentic Memory Search
Agentic search allows you to find memories based on meaning rather than exact keyword matches. This is particularly useful for retrieving contextually relevant information:
With agentic search, the model understands the intent behind your query and returns the most relevant memories, even if they don’t contain the exact keywords from your search.