Agent memory infrastructure

Mneme

/ˈniː.miː/ — Greek: memory

A Rust memory engine for AI agents that compresses, evolves, and resolves conflicts in memories — implementing neuroscience mechanisms no existing system has built.

Every existing agent memory system treats memory as a database problem — store, index, retrieve. Mneme treats memory as a living process.

01 — The problem

Current systems forget how to forget

Mem0 appends new facts and hopes the old ones fade. Zep builds a temporal graph but never rewrites nodes. Letta lets the agent page memory in and out but never consolidates it. None of them update a memory when it's retrieved in a new context — the mechanism neuroscience calls reconsolidation.

The result: memory stores that grow without bound, accumulate contradictions, and can't distinguish between "the user changed their mind" and "both things are true in different contexts."

02 — Landscape

What's missing across the field

Mechanism Mem0 Zep Letta Mneme
Reconsolidation No No No Drift-triggered
Dual memory system Single store Single graph 3 tiers (manual) Working + Semantic
Conflict resolution Latest wins No No 3 strategies
Progressive disclosure Load all Load all Agent pages Envelope → Body
Forgetting curve No decay No decay No decay Ebbinghaus decay
Language Python Python Python Rust
03 — The three operations

Compaction, evolution, conflict resolution

Three operations that map directly to mechanisms in cognitive neuroscience. Together they transform a passive memory store into a living knowledge system.

Operation 1

Compaction

Working memory entries from agent sessions get embedded, clustered by similarity, and synthesized into semantic engrams via LLM. Raw observations become distilled knowledge. If a similar semantic engram already exists, compaction routes to evolution instead.

Neuroscience: hippocampal → neocortical consolidation (CLS theory, McClelland et al. 1995)

Operation 2

Evolution

Every retrieval triggers a drift check — cosine distance between the stored embedding and the current context. If drift exceeds a threshold, the LLM evaluates whether the memory should update, creating a new version while preserving the full supersession chain.

Neuroscience: reconsolidation (Nader, Schafe & LeDoux, 2000)

Operation 3

Conflict resolution

When two engrams contradict, the system selects from three strategies based on evidence strength: temporal supersede (newer wins), confidence merge (synthesize both), or conditional coexist (both true in different contexts). No existing system makes this distinction.

Neuroscience: schema-dependent encoding (Bartlett, 1932)

04 — Token efficiency

Progressive disclosure

Every memory is an Engram with two layers: a lightweight envelope (embedding + metadata + summary) and a full content body (loaded on demand). Search touches thousands of envelopes; the agent reads a handful of summaries; only 2-3 full bodies enter the context window.

ANN search
~100 envelopes, 0.5ms
Read summaries
~10 summaries, ~200 tokens
Load content
~3 bodies, ~500 tokens
Reconsolidate
async, non-blocking
05 — Architecture

Six crates, one workspace

mneme-server
mneme-api
mneme-consolidate
compact / evolve / resolve + LLM prompts
mneme-store
mneme-embed
5 storage backends  ·  2 embedding backends
mneme-core
Engram, Envelope, ContentBody, config

The agent-facing API exposes four verbs: remember(), recall(), expand(), and end_session(). Reconsolidation runs automatically on every retrieval. Compaction fires on session end or buffer threshold.

06 — Quick start

Persistent memory in four lines


// Capture signals during a session
memory.remember("User prefers Rust for systems", "s1").await;
memory.remember("Building a sub-2ms trading engine", "s1").await;

// Retrieve relevant context (ranked summaries)
let ctx = memory.recall("preferred language for trading?", 5).await;

// Expand when you need full detail
let detail = memory.expand(ctx[0].id).await;

// End session → memory compacts automatically
memory.end_session("s1").await;
  
07 — Foundations

Built on neuroscience, not analogy

Most agent memory systems reference neuroscience metaphorically. Mneme implements the actual mechanisms — with specific parameters mapped from the literature.

  1. Complementary Learning Systems
    McClelland, McNaughton & O'Reilly, 1995
    → Working memory (fast) + Semantic memory (slow)
  2. Memory reconsolidation
    Nader, Schafe & LeDoux, 2000
    → Drift-triggered evolution on every retrieval
  3. The forgetting curve
    Ebbinghaus, 1885
    → Confidence decay: time_decay(λ) = e^(-λt)
  4. Working memory model
    Baddeley, 2000
    → Progressive disclosure as attentional gating
  5. Schema-dependent encoding
    Bartlett, 1932
    → Context-dependent conflict resolution

MIT licensed. Framework-agnostic. Use as a library or HTTP server.