Recall & Retrieval
recall() (POST /v1/memories/recall) is MemoryLayer’s main read path. Recall is more than vector similarity. It runs a small retrieval pipeline: several ranked candidate lists are fused, graph neighbours are pulled in, and each result is annotated with why it matched. Every feature on this page is part of core MemoryLayer (Apache-2.0).
results = await client.recall( query="What did we decide about the payments database?", limit=10,)for m in results.memories: print(m.relevance_score, m.match_signals, m.content)print(results.retrieval_confidence, results.query_intent)const results = await client.recall("What did we decide about the payments database?", { limit: 10,});The Recall Pipeline
In the default rag mode, a recall request runs these steps:
- Cache check. Repeated identical queries are answered from the recall cache. Writes invalidate it.
- Query intent classification. Rule-based, with no LLM call (see Query intent).
- Candidate retrieval. A dense vector search and a keyword (FTS5 / BM25) search are fused with Reciprocal Rank Fusion (RRF). Any other enabled retrieval channels are fused in the same way.
- Scoring. Scope boosts, recency, alias boosts, and optional backlink salience are applied.
- Graph expansion. Association edges are followed (breadth-first) to pull in connected memories.
- Reranking. An optional reranker or MMR diversification is applied, then the list is truncated to
limit. - Detail level and budget. Each memory is returned at the requested detail level, trimmed to
budget_tokensif you set one. - Annotation. Each result gets
match_signals, a trust score, and a freshness score. The response gets aretrieval_confidencerating.
Recall Modes
| Mode | What it does |
|---|---|
rag (default) | The pipeline above. No LLM call. |
llm | Rewrites the query with the configured LLM, then searches. |
hybrid | Runs rag first, then falls back to llm when the top result scores below rag_threshold (default 0.8). |
agentic | An iterative, LLM-controlled expand / re-query / stop loop, implemented by MemoryLayer Enterprise. A core server takes the hybrid path for this value. |
llm, hybrid, and agentic need an LLM provider and a generation policy that permits query rewriting.
Retrieval Channels
Each channel produces its own ranked candidate list, which is RRF-fused with the vector ranking. Fusion follows a rank discipline: a channel can promote a relevant memory that the vector search missed, but it cannot push strong direct hits out of the results.
| Channel | Default | Env var | What it adds |
|---|---|---|---|
| Keyword (hybrid) | on | MEMORYLAYER_HYBRID_SEARCH_ENABLED | Full-text BM25 matches. Recovers exact names, identifiers, and rare terms that embeddings miss. |
| Entity-anchored | on | MEMORYLAYER_ENTITY_ANCHOR_ENABLED | Memories whose speaker or entity set overlaps the entities named in the query. |
| Fact | off | MEMORYLAYER_FACT_CHANNEL_ENABLED | Atomic fact memories produced by fact decomposition. |
| Graph traversal | off | MEMORYLAYER_GRAPH_RECALL_ENABLED | A small, bounded neighbourhood of memories that mention the query’s canonical entities. Requires the entity registry. |
| Cue anchor | off | MEMORYLAYER_CUE_CHANNEL_ENABLED | Short “entity + aspect” cue keys. Cue generation and storage need a backend that implements them (MemoryLayer Enterprise). On core SQLite, this channel has nothing to search. |
Each channel has its own RRF constant (*_RRF_K, default 60). The fact, cue, and graph channels also have a candidate-pool size (MEMORYLAYER_FACT_CHANNEL_POOL = 200, MEMORYLAYER_CUE_CHANNEL_POOL = 50, MEMORYLAYER_GRAPH_RECALL_POOL = 50).
Bounded typed-relation recall (MEMORYLAYER_RELATIONAL_RECALL_ENABLED, default on) also runs when the request allows it (include_relations, default true). It answers relation-shaped queries from typed entity relations and returns the paths it followed in relation_paths.
Query Intent
Before retrieval, the query is classified into one or more intent labels: entity, temporal, event, or general. The classifier uses deterministic rules and makes no LLM call. The labels come back in query_intent. Intent only fills in parameters you left unset:
- Temporal / event queries raise the recency weight to
0.5. - Explicit date ranges that parse confidently (for example “in March 2026”) become an
event_after/event_beforewindow. This is the only intent effect that can drop results. - Entity queries multiply the alias and backlink boosts by 1.5 and turn on graph expansion.
Disable classification with MEMORYLAYER_QUERY_INTENT_ENABLED=false. A separate flag, MEMORYLAYER_INTENT_CHANNEL_SELECT_ENABLED (default off), lets the intent choose which retrieval channels run. Channel selection only ever removes channels. An unknown or low-confidence intent falls back to the full default set.
Temporal Recall
Each memory has an effective time: its event_time if one is set, otherwise its created_at. The server sets event_time during ingestion. For example, the send time of an ingested email becomes its event_time. Recall can filter and order on effective time:
| Parameter | Description |
|---|---|
event_after / event_before | Keep memories whose effective time falls in this window |
time_order | asc or desc orders results by effective time instead of relevance |
created_after / created_before | Filter on storage time instead |
results = await client.recall( query="incidents in the payment service", event_after="2026-03-01T00:00:00Z", event_before="2026-03-31T23:59:59Z", time_order="asc",)const results = await client.recall("incidents in the payment service", { eventAfter: new Date("2026-03-01"), eventBefore: new Date("2026-03-31"), timeOrder: "asc",});Scoring Knobs
| Env var | Default | Effect |
|---|---|---|
MEMORYLAYER_SCOPE_BOOST_SAME_CONTEXT | 1.5 | Multiplier for memories in the caller’s context |
MEMORYLAYER_SCOPE_BOOST_SAME_WORKSPACE | 1.2 | Multiplier for memories in the caller’s workspace (_global gets 1.0) |
MEMORYLAYER_ALIAS_BOOST_WEIGHT | 0.1 | Boost when a query term matches a memory’s metadata.aliases. Aliases are also indexed for full-text search. |
MEMORYLAYER_BACKLINK_BOOST_WEIGHT | 0.0 | Log-scale boost by graph in-degree. Off by default because it favours generic “hub” memories. similar_to edges never count. |
MEMORYLAYER_RERANKER_PROVIDER | none | none, embed_server, rrf, llm, or hyde |
MEMORYLAYER_RERANK_MMR_ENABLED | false | Maximal Marginal Relevance diversification, so near-duplicates do not fill the top-k. Cannot be combined with the cross-encoder reranker. |
MEMORYLAYER_RERANK_MMR_LAMBDA | 0.5 | Relevance/diversity balance (1.0 means no diversification) |
MEMORYLAYER_MEMORY_RECALL_OVERFETCH | 3 | Candidate pool multiplier before reranking. Results are reranked before truncation, so recall never returns more than limit. |
MEMORYLAYER_MEMORY_INCLUDE_ASSOCIATIONS | true | Default for include_associations (graph expansion) |
MEMORYLAYER_MEMORY_TRAVERSE_DEPTH | 2 | Default expansion depth |
MEMORYLAYER_MEMORY_MAX_GRAPH_EXPANSION | 50 | Maximum memories added by expansion |
MEMORYLAYER_RECALL_SUPERSESSION_MODE | off | off, demote, or exclude for memories superseded by newer ones |
Request Parameters
The most-used POST /v1/memories/recall fields:
| Field | Default | Description |
|---|---|---|
query | required | Natural-language query |
mode | rag | See Recall modes |
limit / offset | 10 / 0 | Page size (1–100) and offset |
types, subtypes, tags | — | Filters (tags use AND logic) |
context_id, observer_id, subject_id, user_id | — | Scope and perspective filters |
include_global | true | Also search the _global workspace |
include_global_user | true | Also search the caller’s user-scoped memories. Only takes effect when user_id is set. |
tolerance / min_relevance | moderate / tolerance floor | Relevance cut-off (see Search Tolerance) |
recency_weight | server default | 0.0 (off) to 1.0 |
include_associations, traverse_depth, max_expansion | server defaults | Graph expansion controls |
detail_level | full | abstract, overview, or full |
budget_tokens | — | Hard estimated-token budget for the returned content |
exclude_ids | [] | Memory IDs to skip, such as ones already shown |
include_archived | false | Include archived memories |
include_embeddings | false | Return raw vectors (large; off by default since 0.2.0) |
include_confidence | true | Compute retrieval_confidence |
include_relations | true | Allow typed-relation recall |
Not every SDK exposes every field. The Python SDK’s recall() does not currently take observer_id, subject_id, or detail_level, for example. Call the REST endpoint directly when you need them.
Reading the Result
| Field | Description |
|---|---|
memories[].relevance_score / boosted_score | Raw score and score after boosts |
memories[].match_signals | Which retrieval signals matched this memory |
memories[].source_scope | same_context, same_workspace, global_workspace, global_user_workspace, association, or other |
memories[].trust_score, trust_signals | Composite trust score and its components |
memories[].freshness_score | Exponential freshness (half-life MEMORYLAYER_FRESHNESS_HALF_LIFE_DAYS, default 7) |
mode_used | The mode that actually produced the results |
query_intent | Classified intent labels |
retrieval_confidence | strong, moderate, or weak, with confidence_reasons |
budget_summary | Tokens requested and used, plus counts of truncated and omitted items |
generation_summary | LLM calls and tokens spent on this request |
relation_paths | Typed-relation paths used to answer the query |
drift_caveat | A warning when some returned memories have low trust |
Generation Policy
MEMORYLAYER_ENRICHMENT_POLICY controls whether the server may call an LLM at all:
| Policy | Behaviour |
|---|---|
generative (default) | LLM-backed enrichment and query features run when an LLM provider is configured |
adaptive | Only the activities listed in MEMORYLAYER_ADAPTIVE_GENERATION_ACTIVITIES (default reflection,synthesis) may generate |
deterministic | No generative calls. Requests that explicitly need generation, such as mode: "llm", are rejected with generation_not_allowed. |
Per-operation caps are set with MEMORYLAYER_GENERATION_MAX_CALLS (8), MEMORYLAYER_GENERATION_MAX_INPUT_TOKENS (100000), and MEMORYLAYER_GENERATION_MAX_OUTPUT_TOKENS (16384).
Measuring Retrieval Quality
To check the effect of a change to any of these settings, run the memorylayer-eval harness. See Retrieval Evaluation.