Edit this page on GitHub ↗

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

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

  1. A turn settles.
  2. An extractor proposes relics with kind, text, importance, confidence and source.
  3. A deduper checks for contradictions and near-duplicates.
  4. A writer appends the relic with branch_id and source_turn.
  5. If it contradicts an active relic, the old one is superseded, not deleted.
  6. The relationship and Canon are updated if relevant.

Extraction is asynchronous. The chat path only reads.

The reference kernel implements the reconciliation:

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