How recall decides
Three retrievers fan out, their ranks fuse with RRF at k=60, a filter chain trims, and a relevance band — not a top-K cut — decides whether the answer is Single, Many or None.
recall is Brain's sole client read verb, and there is one code path. A
request does not pick a strategy, a retriever or a ranking mode; the only thing
that changes the path at all is whether the request carries a txn_id (see
read-your-writes below).
The pipeline:
validate → embed cue → fan out to three retrievers
→ RRF fusion (k = 60, weighted)
→ filter chain
→ metadata enrichment
→ recency boost (only on a temporal query)
→ rerank (only if a cross-encoder is loaded — off by default)
→ merge / diversity (only on list intent)
→ membership band → Single | Many | NoneEach stage below is one of those lines.
Three retrievers, always wired
A single ranking signal fails predictably. Vectors miss exact tokens — error codes, surnames, SKUs — because an embedding blurs precisely the strings you needed matched. Keyword search misses paraphrase. Neither knows that two memories are about the same person.
So all three run, in parallel, on every request. They are mandatory shard wiring: declaring a schema does not switch them on, and no request flag turns one off.
SemanticHNSW over embeddingsCosine similarity over the memory and statement vector indexes (384-dim). Catches paraphrase — "what theme does she like" finding "prefers dark mode".
Lexicaltantivy BM25BM25 (k1 = 1.2, b = 0.75) over memory text and the statement's textual
form. Tokenisation preserves URLs, code identifiers and IDs like
ACME-1247, which is exactly what the embedding smooths away.
Graphentity-joined traversalStarts from the entities your cue refers to and walks the typed graph — star, path or k-hop subgraph. Default depth 3, capped at 5. Finds what is connected rather than what is worded similarly.
Their scores are not comparable with each other — cosine is bounded, BM25 is
not, graph proximity is 1/(hop + 1). That is why fusion uses rank, never
score.
They also fail independently, and the pipeline is built to tolerate it. An empty corpus for a lane returns an empty list and fusion degrades gracefully; a lane that times out is cancelled and fusion proceeds with whatever arrived, with the timeout surfaced as an operator metric rather than an error to the caller. A slow graph traversal cannot hold up an answer the other two lanes already have.
The router decides weights and budget
A rule-based query router classifies the cue before the lanes run, and sets both the per-retriever weight and how deep each lane searches. Shipped defaults:
| Query class | Semantic | Lexical | Graph | Top-K per lane |
|---|---|---|---|---|
| Entity-anchored — "about Priya" | 0.8 | 0.5 | 2.0 | 50 |
| Exact-term — "ACME-1247" | 0.5 | 2.0 | 0.5 | 30 |
| Paraphrase-likely — "how does she feel about" | 1.5 | 0.5 | 1.0 | 100 |
| Default / ambiguous | 1.0 | 1.0 | 1.0 | 100 |
Absent a classification the standing weights are semantic 1.0, lexical 1.0, graph 1.2 — the graph lane is trusted slightly more because an entity join is a stronger signal than a word match when it fires at all.
The per-lane cut is real and it bites. Each retriever contributes at most its top-K; items past that rank never enter fusion. A memory ranked 250th by semantic but 1st by lexical still gets its lexical rank-1 contribution — but a memory ranked 250th in every lane is not in the pool at all, and no amount of downstream tuning will surface it. If an answer you expected never appears, check that it was written before you tune anything.
Fusion: rank, not score
The three ranked lists merge with Reciprocal Rank Fusion:
RRF_score(d) = Σᵢ wᵢ / (k + rankᵢ(d)) k = 60A document absent from a lane contributes zero from that lane. Three properties are why this is the default rather than a weighted sum of normalised scores:
- Scale-invariant. It does not matter that cosine is
[0, 1]and BM25 is unbounded. Only positions are read. - Stable under score noise. If two candidates sit at cosine 0.812 and 0.811, RRF treats them as ranks 3 and 4 rather than as a near-tie that a normalisation step might invert.
- Flat tail. At
k = 60rank 1 contributes1/61 ≈ 0.0164and rank 10 contributes1/70 ≈ 0.0143— a ratio of about 1.15. One lane loving a result cannot dominate three lanes mildly agreeing, which is the behaviour you want: agreement across different kinds of evidence beats enthusiasm from one.
Raising k flattens further (good when individual rankings are noisy);
lowering it sharpens the head (good when lanes are well calibrated).
The filter chain
Fusion ranks; the filter chain decides eligibility. It drops tombstoned rows, then applies kind, session, temporal, confidence, salience and supersession filters. On the wire these are flat fields rather than a nested struct, so the server never has to tell an absent filter from an empty one:
| Field | Default | Meaning |
|---|---|---|
kind_filter | None | restrict to specific memory kinds |
session_filter | None | restrict to sessions; None spans the space |
salience_floor | 0.0 | minimum salience |
age_bound_unix_nanos | None | event-time lower bound |
as_of_record_time_unix_nanos | None | bi-temporal record-time anchor — what did we believe in August? |
confidence_threshold | 0.0 | drop below this calibrated confidence |
There are no tag and no custom-metadata filters, because memories carry neither. Structured attributes live on entities and statements, which the typed graph queries directly. There is likewise no embedding-fingerprint toggle: a memory stamped with a different model is not comparable to the current query vector at all, so excluding it is not an opt-in.
Recency, only when the question is temporal
A fourth weight rides alongside the three lanes — temporal, default 0.5 —
but it is not a retriever. It is an additive boost folded in after filtering:
boost(d) = temporal_weight · 1/(k + 1) · 0.5 ^ (age(d) / half_life)
age(d) = reference_time − (occurred_at(d) ?? created_at(d))Three things keep it honest. It is capped at 1/(k+1) — one top-rank
retriever vote — so at the default weight a brand-new memory earns at most
half of one such vote: a tie-breaker between comparably relevant hits, never
something that overrides relevance. The half-life is 90 days. And it is gated
on a temporal signal — a time expression the router detected, an explicit
time filter, or an as_of anchor — so timeless facts like "what is my wife's
name" are never penalised for being old.
Rerank ships disabled
A cross-encoder reranker (bge-reranker-base, 110M params) can reorder the top
50 fused candidates, reading each candidate together with the query rather
than comparing two independently produced vectors.
It is off by default and is not part of the current release. [rerank] enabled defaults to false and the published image carries no cross-encoder
model, so the shipped pipeline is RRF-only and rerank_score comes back
None.
The reason is correctness, not cost: rerank only reorders candidates retrieval already surfaced, so it cannot recover a memory the retrieval and grounding stages missed. Fixing recall upstream is the work that matters; turning rerank on is how you A/B the ordering after that work is done.
Two consequences follow from it being a deploy-time load gate rather than a request flag:
- Enabled without a model on disk is a boot failure, not a degradation — the shard refuses to start. That is intended: a silently-degraded reranker would make two shards with identical config return different orderings.
- An opt-in rerank request against a shard with it off hard-fails with
CapabilityNotEnabledrather than quietly falling back to RRF. You are told the capability is off instead of receiving different results with no explanation.GET_CAPABILITIESreportsrerank: false.
Diversity, only on list intent
When the router detects a list or aggregation question, a greedy Maximal
Marginal Relevance pass spreads near-duplicates over a window of 50, so "who
is on the billing team" returns distinct members rather than four paraphrases
of the most salient one. Relevance is the rerank score when present and the
fused score otherwise; redundancy is Jaccard overlap on lowercased token sets;
λ = 0.5.
It cannot regress a single answer — greedy MMR's first pick is always the highest-relevance item, so a lone strong answer stays at rank 1 and only positions 2..N are reordered. There is no client knob.
The membership band decides the shape
This is the stage that makes recall a different thing from a search endpoint,
and the part most worth internalising.
The answer set is not the top-K. It is every candidate in the full filtered pool that clears both an absolute floor and a relative band around the best score in the pool:
member(d) ⟺ score(d) ≥ ABS_FLOOR ∧ score(d) ≥ top × REL_BANDanswer_kind is then pure cardinality of that set:
enum AnswerKind { Single, Many, None }None— nothing cleared the band. Not "here is the closest row I have"; an explicit, branchable absence.Single— one memory is the answer.Many— several memories together are the answer.
max_results (max 1000) is a safety ceiling on how many members a Many may
carry. It never turns a Many into a Single by truncation and it never
suppresses the band. It is not a ranking knob.
A Single answer can carry more than one memory, and this surprises
everyone the first time.
When a grounded typed-graph answer is anchor-scoped, clears the strong-match
floor and is corroborated across lanes, its value is committed as the lead:
answer_kind is set from the committed shape and the committed memory moves
to the front of memories. The rest of the band's membership is retained
below the lead, not discarded.
That is deliberate. An incorrect commit — wrong subject, stale value — can
then only mis-order the response, because the real answer, if it was in the
band at all, is still present in the tail. Dropping the tail was tried and
reverted after it caused exactly that regression. So read
memories[0] for the answer and treat the rest as the evidence it was chosen
from.
What a hit carries
struct RecallResult {
memory_id, text, // text empty unless include_text
similarity_score: f32, // raw cosine — provenance only
fused_score: f32, // what it was actually ranked on
rerank_score: Option<f32>, // None when rerank is off (the default)
confidence: f32, // calibrated, [0, 1]
salience: f32,
kind: MemoryKind, // Episodic | Semantic | Consolidated
space_id, session_id,
created_at_unix_nanos,
occurred_at_unix_nanos: Option<u64>,
last_accessed_at_unix_nanos,
contributing_retrievers: Vec<RetrieverName>, // which lanes surfaced it
edges: Option<…>, // if include_edges
graph: Option<…>, // if include_graph, and it was extracted
}similarity_score and fused_score are not the same number and ranking used
the second one. contributing_retrievers is the field to reach for first when
an answer surprises you — it tells you whether a hit arrived by meaning, by
wording, or by connection.
confidence is per-query; salience is intrinsic to the memory. A
high-salience memory can have low confidence for a given cue (important but
unrelated), and a low-salience memory can have high confidence (clearly the
best of its peers). They are different axes and neither substitutes for the
other.
Scope is a boundary, not a filter
A recall runs against the caller's (namespace, space) by default. Setting
scope = Namespace widens it to every space in the caller's own namespace —
never across namespaces, which is a non-negotiable isolation invariant rather
than a configurable one.
A namespace-wide recall fans out to every shard in parallel, because a
namespace's spaces hash across shards. Each shard runs the pipeline with its
filter widened to namespace_id and returns raw candidates; the router merges
the pools with a second RRF pass, keyed on each hit's within-shard rank
(the one signal comparable across shards, since raw fused scores are normalised
per shard). Membership shaping then runs once over the merged pool, so
Single/Many/None is decided globally rather than per shard.
Results outside your scope are not filtered out of the answer — they were never candidates. The difference is not cosmetic: filtering after retrieval means the data crossed into process memory before being discarded, and your retrieval budget was spent on rows you then threw away.
Read-your-writes is the one exception
A request carrying a txn_id reads against a snapshot including the
transaction's pending writes. This is the only path selector in recall, and
it is not chosen on relevance grounds: the lexical and graph retrievers cannot
see a per-transaction buffer, so read-your-writes requires an overlay. Pending
encodes are scored against the cue vector and merged with the committed list;
tombstoned ids in the buffer drop committed hits; membership then shapes the
combined list as usual. There is no consistency argument — a read is either
inside a transaction or it is not.
Finding out why
Set trace: true and the final response frame carries a populated
RecallTrace. It is zero-cost when false — the pipeline computes the data
either way and discards it unless asked. For the raw fused ranking, which
recall deliberately does not return, the operator debug ops QUERY_EXPLAIN
and QUERY_TRACE expose it.
Recall is not the only read
Two sibling operations exist precisely so you don't bend recall into shapes
it isn't for:
MEMORY_LISTenumerates what's stored, in a stable order, with keyset pagination — no cue, no embedding, no fusion, no relevance suppression. Where recall answers what is relevant, this answers what is here. Page 100 costs what page 1 costs.MEMORY_INSPECTis a keyed point read for one memory, returning its write-artifact bundle: the vector, the stored record, the analysed keyword fields, the generated questions and the typed graph it produced. It answers how was this one memory built.
Reaching for recall with an empty-ish cue to list things is the common
mistake. It will return something, and the something will be shaped by a
relevance band that has no opinion about enumeration.
"Why did it return that?" is the question you will ask most often in production. Reach for the trace before tuning anything — the usual answer is that the memory you expected was never written, or never cleared a per-lane top-K, and no ranking adjustment fixes either.
Try it
In the playground, run Team + role and Cross-team link, then switch to Read and ask who works on billing and who designed the checkout?
That question needs two subjects joined through the graph — no single sentence
you wrote contains the answer, so the semantic and lexical lanes cannot produce
it alone. Check contributing_retrievers on the hits. Then run Reason on
the same space to see the path and the evidence behind the connection.
Was this page helpful?
When facts collide
Preferences supersede, facts contradict, events never move, relations obey cardinality and entities merge — five resolutions for five kinds of collision, and none of them overwrite.
Decay and retention
Salience decays on a kind-dependent half-life, superseded claims close off, tombstones reclaim after a grace period — three mechanisms, three different meanings of "forget".