Memory System
Lifecycle
Every conversation turn flows through four stages:
- Record — user and assistant messages stored with timestamps, session IDs, platform message IDs
- Extract — sleep cycle pulls structured facts, preferences, entities, decisions from raw transcripts
- Consolidate — daily → weekly → quarterly summaries compress old knowledge into progressively denser files
- Recall — on each new message, relevant memories are retrieved and injected into the agent's context
Memory Types
| Type | Description | Example |
|---|---|---|
fact | Extracted statement | "user lives in Budapest" |
decision | A choice made | "chose SQLite over Postgres for local-first" |
preference | Like/dislike | "prefers dark mode" |
event | Something that happened | "deployed v0.3.0 on 2026-04-15" |
lesson | Learned insight | "never run filter-branch on live data" |
feedback | Correction or reaction | "user said the summary was too long" |
story | Narrative/anecdote | "the time the deploy broke at 3am" |
secret | Encrypted at rest (class 3) | API keys, passwords |
Search Modes
| Mode | Stages used | Requirements |
|---|---|---|
hybrid | FTS5 + trigram + embeddings + consolidation | Ollama with embedding model |
fts | FTS5 + trigram + consolidation | No external deps |
signature | Keyword signature Hamming distance | No external deps |
Set via MEMORY_SEARCH_MODE env var. Default: hybrid.
Recall Algorithm
See recall.md for the full 4-layer pipeline, ranking formula, and tuning guide.
Recall rendering
Recall and flashback lines are plain text with an owner-built metadata prefix: type · month · emotion +3 (pride, joy) · confidence 4 · topic coding — text. Unknown fields are omitted, and the prefix counts against the recall byte budget. There is no compressed wire codec.
Darwinism (Memory Fitness)
Memories compete for relevance. The system tracks usage patterns and adjusts visibility:
Signals tracked
| Signal | Column | Effect |
|---|---|---|
| Recall count | recall_count | Frequently recalled → boosted in ranking |
| Last recalled | last_recalled_at | Recent recall → higher recency factor |
| Relevance score | relevance_score | Manual or sleep-assigned importance boost |
| Confidence | confidence | 1-5 scale, affects trust factor in scoring |
| Recall timestamps | recall_timestamps | JSON array of last 20 recall times (spacing effect) |
Promote triggers
- Memory recalled ≥3 times in 30 days → relevance boost
- Spaced recalls (intervals ≥7 days apart) → 1.3× multiplier
- Sleep cycle identifies memory as "core" → tier promotion to
core - User explicitly confirms → credibility rises; corrections go through the owner
correctpath (abmind personal --action correct), never silent edits
Demote triggers
- Never recalled after 90 days → candidate for expiry (
valid_toset) - Contradicted by newer knowledge → kept side by side; the owner resolves via
abmind personal --action correct(conflicts coexist, sleep never rewrites history) - Sleep cycle flags as stale/redundant → consolidated or forgotten through the reviewed mechanism
Multi-user Isolation
Each user gets isolated memory. Configure in ~/.abmind/config/users.json:
{
"users": [
{ "userId": "master", "role": "master", "maxClass": 3, "tools": ["all"] },
{ "userId": "guest-123", "role": "guest", "maxClass": 0, "tools": [] }
]
}| Role | Capabilities |
|---|---|
master | Full access, all classifications, all tools |
user | Read/write, no secrets (class 0-2), limited tools |
guest | Read-only, class 0 only, no memory recording |
See classification.md for the NATO Admiralty Codes system.
Consolidation Tiers
| Tier | Frequency | Content |
|---|---|---|
| Daily | Every sleep cycle | Summary of that day's conversations |
| Weekly | Every 7 days | Compressed weekly themes |
| Quarterly | Every 90 days | High-level patterns and persistent facts |
Consolidation files live in ~/.abmind/memory/consolidation/{daily,weekly,quarterly}/. They're searched by the S6 stage during recall (keyword match against .md file contents).
Entity Graph
Durable knowledge can carry relationships between the entities it names:
alice —[works-at]→ acme
project_x —[uses]→ sqliteSleep extraction proposes entities and relations alongside each durable fact. Abmind validates that both names actually appear in that fact and normalizes them, then derives source-bound edges into the recall projection. Recall (S8) reads those stored edges when a known entity appears in the query; revising the fact re-derives its edges, and superseding or forgetting it removes them from serving. This uses no additional model call at recall or index time, and it respects classification and sealing: sealed or foreign content contributes no edges. Converted rows keep only their remapped historical edges until revised.