All projects

In daily use · architecture case study

Hippocampus

A hybrid AI memory engine combining FTS5, exact vector search, rank fusion, diversity selection, typed freshness, and source recovery inside SQLite.

First covered Updated 5 minute technical case study

My role Memory architecture, retrieval implementation, consolidation, and operating workflow.

Hippocampus retrieval architecture showing lexical and semantic search merged into a focused memory result.

The design question

An AI assistant with no memory starts every conversation from zero. Loading every old conversation solves that problem badly: context becomes expensive, relevant details compete with noise, and the model still has to discover which statements are current.

The real question is narrower and harder: out of everything the system has seen, which few memories belong in front of the agent for this task, and how can the original source remain available when the summary is not enough?

Hippocampus is my answer. It is the memory subsystem inside the Agentic System, built in Python on one SQLite database with two distinct stores and several retrieval stages.

25,863curated and extracted memory rows
200,796raw transcript chunks in Echo
60rank fusion denominator constant
5focused memories returned by default

Database counts inspected September 14, 2026. They describe corpus size, not recall accuracy.

Retrieval architecture Exact words and related meaning meet in one ranking The pipeline keeps useful context while removing repeated or stale results.
QuestionWhat did we decide, and why?
LEXICAL FTS5 with BM25

Finds exact names, commands, phrases, and file references.

Top 30 candidates
SEMANTIC Exact L2 search

Finds related decisions even when the question uses different words.

sqlite-vec · top 30 candidates
RRF merges both rankings MMR reduces repetition Decay weighs type and freshness Result returns five memories
Curated BrainRules · facts · decisions
Echo archiveOriginal transcript chunks

Different memories age at different speeds

A reminder to ship today loses urgency quickly. The decision that explains how shipping works can matter years later. Change the age below to see how much weight each memory keeps.

How fast does a memory lose freshness?

Share of its original recency contribution remaining after 90 days.

Monitoring pingτ = 7 days<1%
Task resultτ = 90 days37%
Insightτ = 180 days61%
Factτ = 365 days78%
Tool or personτ = 730 days88%
Rule or decisionτ = 3,650 days98%

Freshness contributes 15% of the default score. Relevance and importance account for the rest.

How the decay is calculated

The freshness multiplier is exp(−age / τ), with age and the type’s time constant (τ) in days. After one time constant, roughly 37% of the original freshness remains. Relevance and importance keep their weights. Retirement is a separate maintenance step.

Two stores in one SQLite file

“What did we decide?” and “What exactly did we say?” lead to different places.

Brain

Returns the decision an agent can act on. Each concise record carries its type, project, tags, importance, creation time, and consolidation state.

Echo

Recovers the original exchange. An explicit transcript search can surface the wording, alternatives, and reasoning behind a stored decision.

When each layer enters a session
Session start
A small set of shared operating and communication rules loads every time.
Task routing
The subject selects the relevant project guidance, procedures, and skills.
Memory lookup
At task start or on request, Brain returns a focused set of records.
Source lookup
Echo loads original transcript excerpts when the agent asks for them.

How a query becomes five memories

A filename needs an exact match. A decision phrased in new words needs a meaning match. Brain combines both searches, then discounts repeated answers so one decision can’t fill all five slots.

30 + 30candidates at most across the two searches
10diverse candidates at most after selection
5memories returned by default
Inspect all eight retrieval stages
  1. Embed the question

    Brain caches query embeddings in the running process. It uses OpenAI’s text-embedding-3-small with 1,536 dimensions, the same model used for the stored memories.

  2. Search both indexes

    FTS5 ranks literal matches with BM25. The sqlite-vec extension finds the nearest vectors using exact Euclidean distance (L2). Each path returns up to 30 active candidates and can filter by memory tier.

  3. Combine the lists

    Reciprocal rank fusion uses each candidate’s position in both lists with a denominator constant of 60. Brain normalizes the fused scores.

  4. Recognize task language

    Words such as “reminder,” “deadline,” and “next” give tasks and to-dos a small relevance boost.

  5. Make room for variety

    Maximal marginal relevance selects up to ten candidates. It balances relevance (0.65) against similarity to results already selected (0.35).

  6. Score the shortlist

    The default score combines fused relevance (75%), stored importance (10%), and freshness (15%).

  7. Optionally rerank

    The optional Voyage cross-encoder is dormant on this workstation. When configured, its 800 ms timeout, three-failure circuit breaker, five-minute backoff, and daily call cap bound the remote dependency. On failure, Brain keeps its local ordering.

  8. Return the memories

    The default result contains five memories with type, project, date, importance, and score. Source metadata lets the agent inspect a record or look up the original wording in Echo.

Explore the indexes and scoring model

How memory stays current

After a working session goes quiet, an hourly watcher reads the new conversation and extracts what a future agent can reuse.

A day in the memory system
  1. HourlyRead new workProcess eligible sessions after 30 minutes of inactivity.
  2. 11:55 p.m.Catch upCheck the same bookmarks again, including active sessions.
  3. 3:00 a.m.ConsolidateMerge eligible duplicates and retire eligible old tasks.

Schedule shown in workstation time.

How one build fix can become three memories

Suppose a build fails because it ran under the wrong version of Node. From the conversation that fixes it, the watcher can save three short notes.

Fact · semantic
The build reads its Node version from .nvmrc.
Result · episodic
The build passed after switching to the pinned version.
Procedure · inferred
Check the active Node version against .nvmrc before rebuilding.

Each extracted note carries the session tag. If a later agent needs the exact error, it can use that tag to narrow a separate Echo search to the original exchange.

Automatic nightly cleanup

At 3 a.m. workstation time, a scheduled job screens eligible memories for possible duplicates. Only memories with a plausible match need an exact neighbor lookup in SQLite.

Recorded nightly run ·

24,021eligible memories screened
18needed an exact SQLite lookup
69 sfor the full cleanup
Watermarks, consolidation, and retirement

Each session has a watermark that records the last processed position. The watcher resumes there. SQLite’s write-ahead log allows concurrent readers while new records are written. Echo independently chunks and embeds meaningful messages, including exchanges that yield no curated memory.

Nightly consolidation can merge eligible records within an L2 distance of 0.07. The higher-importance record keeps the merged statement and embedding. Repeated procedures can gain confidence. The retired row leaves vector search, and FTS5 is rebuilt as a consistency check.

Curated rules, architecture, and decisions stay protected. Old tasks and to-dos can retire unless pinned or marked canonical.

Follow a record through daily maintenance

What happens when a lookup falls short?

Keyword index offline
Vector search can still find related material. Exact identifiers become easier to miss.
Embedding service offline
A new semantic query requires an embedding. An uncached query stops here.
Reranker unavailable
Brain returns the locally ranked shortlist.
Answer looks stale
The agent can follow the source metadata and check the original conversation in Echo.