Three stores, three shapes
| Store | Cardinality | Mode | Example |
|---|---|---|---|
| User profile | One record per user | ALWAYS (auto-extracted) | “Prefers async communication, based in PT, role: PM” |
| Entity memory | Graph of entities + facts + relationships + events | AGENTIC (agent writes) | Sarah Chen → role: VP Eng → company: Acme → “joined 2024-Q4” |
| Session context | Per session | ALWAYS | ”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:| Tool | What 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 |
User profile
User profile is one record peruser_id, updated in place. Whatever the agent learns about you (your role, your preferences, your working style) goes here.
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.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”.
enable_agentic_memory=True and move to LearningMachine once flat memory feels too lossy.
See it in action
agents/contacts/agent.py, Learning Machine docs