Introduction
Memory for Agents
If you’re building intelligent agents, you need to give them memory which is their ability to learn about the user they are interacting with. Memory comes in 3 shapes:
-
Session Storage: Session storage saves sessions in a database and enables Agents to have multi-turn conversations. Session storage also holds the session state, which is persisted across runs because it is saved to the database after each run. Session storage is a form of short-term memory called “Storage” in Agno.
-
User Memories: The Agent can also store insights and facts about the user it learns over time. This helps the agents personalize its response to the user it is interacting with. Think of this as adding “ChatGPT like memory” to your agent. This is called “Memory” in Agno.
-
Session Summaries: The Agent can store a condensed representations of the session, useful when chat histories gets too long. This is called “Summary” in Agno.
Memory helps Agents:
- Manage session history and state (session storage).
- Personalize responses to users (user memories).
- Maintain long-session context (session summaries).
Managing User Memory
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 recommend it as the best way to give Agents memory.
With Agentic Memory, The Agent itself creates, updates and deletes memories from user conversations.
Set enable_agentic_memory=True
to enable Agentic Memory.
Create Memories after each run
Set enable_user_memories=True
to trigger the MemoryManager
after each run. We recommend using Agentic Memory but this option is there is you need it.
Memory Architecture
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 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.