The MemoryManager class is responsible for handling the LLM used to create and update memories.
You can adjust it to personalize how memories are created and updated:
Copy
Ask AI
from agno.agent import Agentfrom agno.db.sqlite import SqliteDbfrom agno.memory import MemoryManagerfrom agno.models.openai import OpenAIChat# Setup your databasedb = SqliteDb(db_file="agno.db")# Setup your Memory Manager, to adjust how memories are createdmemory_manager = MemoryManager( db=db, # Select the model used for memory creation and updates. If unset, the default model of the Agent is used. model=OpenAIChat(id="gpt-5-mini"), # You can also provide additional instructions additional_instructions="Don't store the user's real name",)# Now provide the adjusted Memory Manager to your Agentagent = Agent( db=db, memory_manager=memory_manager, enable_user_memories=True,)agent.print_response("My name is John Doe and I like to play basketball on the weekends.")agent.print_response("What's do I do in weekends?")
When using Memory with your Agents, memories about the current user will be added to the agent’s context by default.If you want your Agent to create and update memories, but not have them added to the context of each request to the model, you can use the add_memories_to_context flag:
Copy
Ask AI
from agno.agent import Agentfrom agno.db.sqlite import SqliteDb# Setup your databasedb = SqliteDb(db_file="agno.db")# Setup your Agent with Memoryagent = Agent( db=db, enable_user_memories=True, # This enables Memory for the Agent add_memories_to_context=False, # This disables adding memories to the context)
Often, you will want multiple Agents to share the same memories.
To achieve this, you just need to provide the same database to those agents.
All Agents will then have access to the same memories for a given user:
Copy
Ask AI
from agno.agent import Agentfrom agno.db.sqlite import SqliteDb# Setup your databasedb = SqliteDb(db_file="agno.db")# Setup your Agents with the same database and Memory enabledagent_1 = Agent(db=db, enable_user_memories=True)agent_2 = Agent(db=db, enable_user_memories=True)# The first Agent will create a Memory about the user name here:agent_1.print_response("Hi! My name is John Doe")# The second Agent will be able to retrieve the Memory about the user name here:agent_2.print_response("What is my name?")