Learning Machines

Agents that learn and improve with every interaction.

Agno turns agents into learning machines by combining them with Learning Stores. Learning Stores are persistent backends that capture user profiles, memories, and knowledge over time.

Setup

pip install agno openai sqlalchemy
export OPENAI_API_KEY="your-api-key"
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses

agent = Agent(
    model=OpenAIResponses(id="gpt-5.2"),
    db=SqliteDb(db_file="tmp/agents.db"),
    learning=True,
)

One line. Your agent now remembers users and improves over time.

Learning Stores

Each store captures a different type of knowledge:

StoreWhat it capturesScope
User ProfileStructured facts (name, role, preferences)Per user
User MemoryUnstructured observations from conversationsPer user
Session ContextGoals, plans, and progress for the current sessionPer session
Entity MemoryFacts about external things (companies, projects, people)Configurable
Learned KnowledgeInsights that transfer across usersConfigurable
Decision LogDecisions with reasoning for auditing and learningPer agent

Stores can be enabled individually or combined. Each implements the same protocol: recall, process, build_context, get_tools.

Learning Modes

Control how and when the agent learns:

ModeHow it works
AlwaysExtraction starts concurrently with the main model call
AgenticAgent receives tools and decides what to save
ProposeAgent is instructed to propose learnings and wait for confirmation (prompt-guided)

Namespaces

Some stores support configurable sharing scope via namespace:

NamespaceWho can access
"user"Only the current user
"global"Everyone (default)
CustomExplicit grouping (e.g., "engineering", "sales_west")

Maintenance

The Curator operates on a custom User Profile schema's memories field; it does not maintain the default User Memory store:

lm = agent.learning_machine

# Remove memories older than 90 days
lm.curator.prune(user_id="alice", max_age_days=90)

# Remove duplicates
lm.curator.deduplicate(user_id="alice")

The Curator reads a memories field from the User Profile store, but the default UserProfile schema doesn't define one. prune() and deduplicate() return 0 unless you add a memories field to a custom profile schema and populate it yourself. See User Memory for the current workaround.

Guides

Resources