How it works

Retrieval and search

Memory Layer uses more than one retrieval path because project questions come in different forms. Some questions mention exact files or commands. Others describe behavior in natural language. Some need code relationships rather than text similarity alone.

Retrieval paths

PathBest atExample query
Full-text searchExact identifiers, commands, paths, tags, and known wording“Where is memory mcp run implemented?”
Semantic searchRelated concepts with different wording“How do agents recover context after interruption?”
Graph contextFiles, symbols, references, and code ownership links“What memories are affected by the route split?”
Activity lookupRecent work and operational events“What happened in the last docs-site session?”
History lookupMemory version chains and tombstones“Why was this memory replaced?”

Embeddings

Canonical memories are chunked and embedded into one or more embedding spaces. Each space records provider, model, dimensions, and chunk metadata. This lets a project keep multiple search backends side by side while switching the active retrieval space.

Typical reasons to rebuild embeddings:

  • provider or model changed
  • dimensions changed
  • many memories were added before embeddings were configured
  • diagnostics report missing coverage
  • semantic retrieval quality regressed

Use:

memory embeddings status --project <project-slug>
memory embeddings rebuild --project <project-slug>

Graph-aware retrieval

The code graph links memories to files, symbols, references, and repository structure. This helps when a future question names a code object rather than the exact words in a memory.

Graph context is especially useful after refactors. If a module moved but the memory remains behaviorally true, curation can update navigation facts instead of losing the old knowledge.

Ranking diagnostics

Query results expose why they were returned. Depending on configuration, diagnostics can include:

  • full-text score
  • semantic similarity
  • graph or relation boost
  • tag and path matches
  • confidence and importance
  • recency
  • retrieval and answer-generation timing

Use these diagnostics to decide whether an answer is grounded. A high-quality answer should cite relevant memories and show plausible match reasons, not just produce fluent text.

Failure modes

SymptomLikely causeFirst check
Good exact query returns nothingWrong project slug or missing memorymemory stats --project <slug>
Semantic search is emptyEmbeddings missing or provider downmemory embeddings status --project <slug>
File-specific query misses contextRepo index or graph stalememory repo inspect, memory graph inspect
Answer cites old factsMemory needs replacement reviewTUI Review tab or memory proposals
Query works in CLI but not UIService or API token mismatchmemory status --project <slug>

© 2026 Olivier Van Acker (3vilM33pl3). Memory Layer is AGPL-3.0-or-later with commercial licensing available.

On this page