
Search Pipeline
Whensearch_memories is called, the query goes through a multi-stage pipeline:
Semantic Search
Uses sqlite-vec to perform cosine distance search against thevec_memories table. Returns memories ordered by vector similarity.
The distance is converted to a 0-1 similarity score:
Full-Text Search (BM25)
Uses FTS5 with Porter stemming tokenizer. The FTS index coverscontent and tags fields.
BM25 ranks are normalized to 0-1:
abs() is applied before normalization.
Hybrid Scoring
Each candidate memory receives a weighted score from four components:Default Weights
| Component | Weight | Description |
|---|---|---|
| Semantic | 0.4 | Vector similarity |
| BM25 | 0.3 | Full-text relevance |
| Recency | 0.2 | How recently accessed |
| Salience | 0.1 | Importance decayed over time |
Recency Score
Exponential decay with a configurable half-life (default: 24 hours):Salience Score
Combines the memory’simportance value with time decay:
Filtering
Before scoring, candidates are filtered:- Layer filter — Only include memories from specified layers
- Scope filter — Filter by project or global scope
- TTL filter — Exclude memories past their
expiresAt - Soft-delete filter — Always exclude deleted memories