Quickstart
Enable learning in your agents.
Setup
pip install agno openai sqlalchemy
export OPENAI_API_KEY="your-api-key"Enable Learning
The simplest way: set learning=True.
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
db = SqliteDb(db_file="tmp/agents.db")
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
db=db,
learning=True,
)This enables user profile and user memory extraction in Always mode. The agent automatically captures information and recalls it in future sessions.
Test It
# Session 1: Share information
agent.print_response(
"Hi! I'm Sarah, I work at Acme Corp as a data scientist.",
user_id="sarah@acme.com",
session_id="session_1",
)
# Session 2: Agent remembers
agent.print_response(
"What do you know about me?",
user_id="sarah@acme.com",
session_id="session_2",
)Session 2 is a new conversation, but the agent remembers Sarah.
Choose What Gets Learned
For more control, configure stores individually:
from agno.learn import LearningMachine
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
db=db,
learning=LearningMachine(
user_profile=True, # Structured facts (name, role, preferences)
user_memory=True, # Unstructured observations
session_context=True, # Session summary and goals
entity_memory=False, # Facts about external entities
learned_knowledge=False # Insights across users (requires Knowledge)
),
)See Learning Stores for details on each store.
Choose How Learning Happens
Each store can use a different learning mode:
from agno.learn import (
LearningMachine,
LearningMode,
UserProfileConfig,
UserMemoryConfig,
)
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
db=db,
learning=LearningMachine(
user_profile=UserProfileConfig(mode=LearningMode.ALWAYS),
user_memory=UserMemoryConfig(mode=LearningMode.AGENTIC),
),
)| Mode | How it works |
|---|---|
| Always | Extraction starts concurrently with the main model call |
| Agentic | Agent receives tools and decides what to save |
| Propose | Agent is instructed to propose learnings and wait for confirmation (prompt-guided) |
See Learning Modes for details.
Production Database
For a PostgreSQL-backed deployment, install the driver and start the database (Docker required for this local example):
pip install "psycopg[binary]"Run PgVector
docker run -d \
-e POSTGRES_DB=ai \
-e POSTGRES_USER=ai \
-e POSTGRES_PASSWORD=ai \
-e PGDATA=/var/lib/postgresql \
-v pgvolume:/var/lib/postgresql \
-p 5532:5432 \
--name pgvector \
agnohq/pgvector:18from agno.db.postgres import PostgresDb
db = PostgresDb(db_url="postgresql+psycopg://ai:ai@localhost:5532/ai")
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
db=db,
learning=True,
)