Using Memory, you can enable your Agents to recall information about the user. When relevant information about the user is available in the conversation, an Agent with Memory will store it in the database. It will later be able to retrieve that information when relevant, effectively learning about the user!

Usage

To get started, let’s setup a basic Agent with Memory. For that, you will need to setup a database and configure your Agent as follows:
from agno.agent import Agent
from agno.db.sqlite import SqliteDb

# Setup your database
db = SqliteDb(db_file="agno.db")

# Setup your Agent with Memory
agent = Agent(
    db=db,
    enable_user_memories=True, # This enables Memory for the Agent
)

Agentic Memory

When configuring your Agent with enable_user_memories=True, memories will be automatically created/updated after each run. You can also give the Agent full control over the memory management by using enable_agentic_memory=True:
from agno.agent import Agent
from agno.db.sqlite import SqliteDb

# Setup your database
db = SqliteDb(db_file="agno.db")

# Setup your Agent with Memory
agent = Agent(
    db=db,
    enable_agentic_memory=True, # This enables Agentic Memory for the Agent
)
In this case, the Agent will be equipped with a tool to create, update or delete memories when it deems it relevant.

Where are memories stored?

Memories are stored in the database you provide to the Agent. In the Storage section, you can read more about adding a database to your Agent and which databases are supported. By default, memories are stored in the agno_memories table of the database. If the table or collection doesn’t exist, it is created automatically when first storing a memory.
from agno.agent import Agent
from agno.db.postgres import PostgresDb

# Setup your database
db = PostgresDb(
    db_url="postgresql://user:password@localhost:5432/my_database",
    memory_table="my_memory_table", # Specify the table to store memories
)

# Setup your Agent with the database
agent = Agent(db=db, enable_user_memories=True)

# Run the Agent. This will store a session in our "my_memory_table"
agent.print_response("Hi! My name is John Doe and I like to play basketball on the weekends.")

agent.print_response("What are my hobbies?")

Retrieval

You can manually retrieve memories about a certain user from the database using the get_user_memories method:
from agno.agent import Agent
from agno.db.postgres import PostgresDb

# Setup your database
db = PostgresDb(
    db_url="postgresql://user:password@localhost:5432/my_database",
    memory_table="my_memory_table", # Specify the table to store memories
)

# Setup your Agent with the database
agent = Agent(db=db)

# Run the Agent. This will store a memory in our "my_memory_table"
agent.print_response("I love sushi!", user_id="123")

# Retrieve the memories about the user
memories = agent.get_user_memories(user_id="123")
print(memories)

Data Model

These are the fields stored in the database when using Memory:
FieldTypeDescription
memory_idstrThe unique identifier for the memory.
memorydictThe memory data, stored as a JSON object.
topicslistThe topics of the memory.
inputstrThe input that generated the memory.
user_idstrThe user ID of the memory.
agent_idstrThe agent ID of the memory.
team_idstrThe team ID of the memory.
updated_atintThe timestamp when the memory was last updated.
This data is best displayed on the Memories page of the AgentOS UI.

Developer Resources