Skip to main content
Imagine a customer support agent that remembers your product preferences from last week, or a personal assistant that knows you prefer morning meetings, but only after you’ve had coffee. This is the power of Memory in Agno.

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:
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
)
With 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.
from agno.agent import Agent
from agno.db.sqlite import SqliteDb

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

# Setup your Agent with Automatic User Memory
agent = Agent(
    db=db,
    enable_user_memories=True, # Automatic memory management
)

# Memories are automatically created from this conversation
agent.print_response("My name is Sarah and I prefer email over phone calls.")

# And automatically recalled here
agent.print_response("What's the best way to reach me?")
Best for: Customer support, personal assistants, conversational apps where you want consistent memory behavior.

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.
from agno.agent import Agent
from agno.db.sqlite import SqliteDb

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

# Setup your Agent with Agentic Memory
agent = Agent(
    db=db,
    enable_agentic_memory=True, # This enables Agentic Memory for the Agent
)
With agentic memory, the agent is equipped with tools to manage memories when it deems relevant. This gives more flexibility but requires the agent to make intelligent decisions about what to remember. Best for: Complex workflows, multi-turn interactions where the agent needs to decide what’s worth remembering based on 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 the agno_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:
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?")

Manual Memory Retrieval

While memories are automatically recalled during conversations, you can also manually retrieve them using the get_user_memories method. This is useful for debugging, displaying user profiles, or building custom memory interfaces:
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)

Memory Data Model

Each memory stored in your database contains the following fields:
FieldTypeDescription
memory_idstrThe unique identifier for the memory.
memorystrThe memory content, stored as a string.
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.
View and manage all your memories visually through the Memories page in AgentOS/

Developer Resources

I