Skip to main content
The Contacts agent is a mini CRM that remembers people, the facts you tell it about them, who knows whom, and what’s happening between them. Three memory stores, each scoped to a different shape of state:
from agno.learn import (
    LearningMachine, LearningMode,
    UserProfileConfig, EntityMemoryConfig, SessionContextConfig,
)

contacts = Agent(
    id="contacts",
    name="Contacts",
    model=MODEL,
    db=agent_db,
    learning=LearningMachine(
        user_profile=UserProfileConfig(mode=LearningMode.ALWAYS),
        entity_memory=EntityMemoryConfig(
            mode=LearningMode.AGENTIC,
            enable_create_entity=True,
            enable_add_fact=True,
            enable_add_relationship=True,
            enable_add_event=True,
        ),
        session_context=SessionContextConfig(
            mode=LearningMode.ALWAYS,
            enable_planning=True,
        ),
    ),
    enable_agentic_memory=True,
)

Three stores, three shapes

StoreCardinalityModeExample
User profileOne record per userALWAYS (auto-extracted)“Prefers async communication, based in PT, role: PM”
Entity memoryGraph of entities + facts + relationships + eventsAGENTIC (agent writes)Sarah Chen → role: VP Eng → company: Acme → “joined 2024-Q4”
Session contextPer sessionALWAYS”User is planning a Q1 offsite, talking through agenda”
LearningMode.ALWAYS runs an extractor on every turn. LearningMode.AGENTIC gives the agent tools to write when it judges something worth keeping.

Entity memory in detail

The Contacts agent gets four entity-memory tools when configured as above:
ToolWhat it does
create_entity(name, type)Adds a new entity (Person, Company, Project, …)
add_fact(entity, fact)Attaches a fact to an entity
add_relationship(entity_a, entity_b, type)Links two entities
add_event(entity, event, when)Records a time-bound event
Example chat that builds up the graph:
User: Sarah Chen joined Acme as VP Engineering last month.
Contacts: → create_entity("Sarah Chen", "Person")
          → add_fact("Sarah Chen", "VP Engineering at Acme")
          → add_relationship("Sarah Chen", "Acme", "employed_by")
          → add_event("Sarah Chen", "joined Acme as VP Eng", "2026-03-15")
Next session, “what do I know about Sarah?” returns the full picture without the user re-telling.

User profile

User profile is one record per user_id, updated in place. Whatever the agent learns about you (your role, your preferences, your working style) goes here.
User: I prefer concise responses, no preamble.
Contacts: → user_profile updated: { communication_style: "concise, direct" }
Future responses across any session, any agent that shares the same db, get terser automatically.

Session context

Session context is plan-shaped. “What’s this conversation actually about? What does the user want by the end?” The agent uses it to keep multi-turn plans coherent.
Session goal: Plan Q1 offsite agenda
Open items: pick venue, set theme, draft schedule
Decisions so far: 3 days, 25 people, focus on roadmap alignment
Useful for long, exploratory sessions where the user pivots and the agent needs to stay anchored.

Vanilla agentic memory vs LearningMachine

For most agents, enable_agentic_memory=True is enough: a single bucket of facts that the agent writes to via tools. LearningMachine is right when the shape of memory matters:
  • A relationship graph (Contacts) needs entities and edges, not flat strings.
  • A long-running personal agent (Pal) needs to separate “what I know about you” from “what I know about your domain”.
  • A self-improving SQL agent (Dash) needs to separate “validated queries” from “error patterns I’ve fixed”.
When in doubt, start with enable_agentic_memory=True and move to LearningMachine once flat memory feels too lossy.

See it in action

@Contacts Sarah Chen joined Acme as VP Eng last month
@Contacts what do I know about Sarah?
@Contacts who at Acme have I been talking to?
@Contacts I'm meeting Sarah tomorrow about the platform roadmap
@Contacts later: what was the meeting with Sarah about?
Each turn updates the entity graph. The agent uses the graph on every retrieval. Source: agents/contacts/agent.py, Learning Machine docs

Next

Learning →