Memory
Lares treats memory as a systems problem, not a prompt problem. A companion that forgets is not a model failure; it is a missing data model.
Relics
A memory is a relic: a small, typed record with provenance.
| Field | Meaning |
|---|---|
kind |
fact, event, preference, promise, relationship |
text |
The memory in natural language. |
importance |
0..1, used in retrieval and decay. |
confidence |
0..1, extraction confidence. |
branch_id |
The timeline it belongs to. |
source_turn / source_id |
The turn and message that produced it. |
status |
active, superseded, tombstoned. |
parent_id |
Fork lineage. |
Every model-visible memory has provenance. A fact the model cannot attribute does not enter the prompt.
Retrieval
score = 0.60 * relevance
+ 0.25 * importance
+ 0.15 * recency
- relevance is Jaccard over lightly stemmed tokens; CJK uses character bigrams.
- importance is the stored weight.
- recency is
0.5 ** (age / half_life), with a default half-life of 7 days.
When embeddings exist, relevance becomes a hybrid: half keyword, half cosine. Vectors live in memory_embeddings and never appear in API payloads. Missing vectors, provider errors, and dimension mismatches fall back to the keyword score, so retrieval degrades instead of failing.
retrieve also enforces max_chars and touches selected relics, so recency reflects use.
The write pipeline
- A turn settles.
- An extractor proposes relics with kind, text, importance, confidence and source.
- A deduper checks for contradictions and near-duplicates.
- A writer appends the relic with
branch_idandsource_turn. - If it contradicts an active relic, the old one is superseded, not deleted.
- The relationship and Canon are updated if relevant.
Extraction is asynchronous. The chat path only reads.
The reference kernel implements the reconciliation:
- an exact or near-duplicate (Jaccard ≥ 0.8, same kind) is skipped and the existing relic's weight is refreshed;
- a preference flip supersedes the old relic with
supersede_reason: contradiction; - everything else is appended as a new active relic.
Branches
A conversation can fork. Each relic belongs to exactly one branch, and a branch carries its lineage through parent_id.
Rollback does not delete. It tombstones every memory after the rollback turn, so a future the user did not choose cannot leak into the next branch. The old rows stay auditable.
Decay and maintenance
Importance decays with time and use. lares maintain applies decay, consolidates duplicates, backfills embeddings, and prunes retention. A decayed relic is still readable; it simply stops crowding retrieval.
Corrections
A user correction supersedes the old relic. The old one remains, with a reason. This is the difference between a memory you can trust and a transcript you have to re-read.
Read next
- Persona and proactivity: how memory becomes a voice.
- Operations: retention, DSAR and tenancy.