Retrieval
How a recall finds candidates, ranks them, and compiles them into one token-budgeted context — and the request options that change each step.
A recall is one call — POST /v1/memory/retrieve, search() in the SDKs or search_memory over MCP — that returns a single context: every memory type assembled, ranked and fitted to a token budget, plus a receiptId naming exactly what was delivered.
What comes back
The response is a MemoryContext object. Sections are always present (empty when nothing matched):
| Field | Contents |
|---|---|
receiptId | The receipt of this delivery. |
blocks | Memory blocks visible to the agent. Always included. |
userProfile | The end user's profile, when the request names a userId. |
platformEntries | Platform policies and defaults. |
tenantFloors | Non-negotiable tenant policies. |
tenantEntries | Approved tenant conventions. |
workspaceEntries | Ranked workspace memory, best match first. |
procedures | Learned procedures relevant to the query. |
relevantEpisodes | Similar past runs. |
fileDocs | Documented files relevant to the query. |
sessionSummary, sessionEntries | The current run's compressed summary and recent entries. |
omittedWorkspaceCount | Matches dropped to fit the budget. Truncation is never silent. |
supersededHiddenCount | Matches hidden because a newer memory replaced them. |
compilation | The budget, tokens used and per-section included / dropped / tokens. Null in raw mode. |
diagnostics | Request-level diagnostics, only with explain: true. |
Every entry carries its provenance (sourceKind, sourceRef, extractionMethod), bi-temporal fields, policy fields (visibility, ownerAgentId, classification), version and a read-time trust breakdown.
Finding candidates
Workspace memory is searched by several legs in parallel and the results are fused with reciprocal-rank fusion:
- Vector — embedding similarity (a minimum cosine similarity applies,
retrieval.minVectorSimilarity, default 0.25) - Full text — keyword search
- Graph — memories connected to strong matches by relationships
- Entity — memories that mention the same entities
- Episode derivatives — sentence-level fragments of past episodes
Before any leg runs, the caller's scope is compiled into it: tenant, workspace, application, visibility and (when given) userId and tag filters. A memory you may not see is never a candidate.
Ranking
Fused candidates are rescored with five factors — fusion rank, recency, access frequency, importance and confidence — and an adaptive score floor removes weak matches. Optionally:
- Value-aware selection blends each memory's learned utility (from outcomes) into the ranking. Off by default; enable it with the workspace setting
retrieval.valueAware.enabled. - Reranking asks the configured LLM to reorder the top results. It only happens in
assistedmode.
Assisted vs deterministic
mode | Behaviour |
|---|---|
deterministic | Zero generative-model calls on recall. Reproducible. The default (retrieval.mode). |
assisted | Recall may call the LLM to decompose the query and rerank results. |
Sending mode: "deterministic" together with rerank: true is contradictory and is rejected with 400.
Compiling the context
Ranked results are compiled into the response under a token budget, counted with a real tokenizer (cl100k). The default is the workspace setting retrieval.tokenBudget (4,000 tokens); a request can pass tokenBudget between 256 and 32,000.
- An item that does not fit is skipped, not the rest of its section.
- Platform policies and tenant floors are never truncated. If the requested budget cannot hold them, the request fails with
422 CONTEXT_BUDGET_TOO_SMALLand both numbers (requestedTokens,requiredTokens). compilationreports what was included and dropped per section.
Pass raw: true to skip the score floor and the budget entirely: topN is honoured literally and the context is returned untrimmed (useful for RAG and evaluation pipelines).
Superseded and historical memories
Memories that a newer memory has replaced are hidden by default on every retrieval path. To see them:
includeSuperseded: truereturns them withsupersededAtandsupersededByset.asOfslices the store at an instant, on thevalidaxis (what was true in the world — the default) or thetransactionaxis (what the system knew), chosen withasOfAxis.
The workspace setting retrieval.hideSuperseded can switch the default off.
Request options
| Field | Type | Effect |
|---|---|---|
semanticQuery | string | The natural-language query. Optional — without it you get blocks, profile, policies and session context. |
runId | string | The run this recall belongs to. Session memory and the receipt are tied to it — reuse the task's runId. |
userId | string | Include this user's profile and narrow to their memories. |
applicationId | GUID | Scope to an application (plus the workspace-wide pool). |
topN | int | Candidate pool size, clamped to 1–100. |
tokenBudget | int | 256–32,000. |
minScore | number | Absolute score floor instead of the adaptive one. |
mode | assisted | deterministic | See above. |
rerank | bool | false skips the reranker, true forces it (assisted only). |
tags | object | Narrow to memories carrying these tag pairs, e.g. {"facet":"auth"}. |
includeSuperseded | bool | Return replaced memories too. |
asOf, asOfAxis | timestamp, valid | transaction | Point-in-time view. |
temporalBefore, temporalAfter | timestamp | Only memories created before/after this instant. |
temporalAnchor | timestamp | Prefer memories created close to this instant. |
expandSessions, expandSessionCount, expandSessionWindow | bool, int, int | Return whole top-ranked runs (default 5) or a ±N-entry window around each match. |
raw | bool | Skip floor and budget. |
explain | bool | Add a per-entry explanation and request diagnostics. |
overrides | object | Per-request experiment knobs: rrfK, legWeights, factorWeights, utilityWeight, valueAware, scoringVersion. |
excludeSuperseded is still accepted for compatibility but ignored.
"Why was this recalled?"
With explain: true, each entry gains an explanation — which legs found it with what rank and raw score, its fusion contribution, factor contributions, the floor, reranker status and trust — and the response gains diagnostics: candidates per leg, fused count, drops by reason (including policy drops), floors and stage latencies. Over MCP, search_memory(..., explain=true) appends a "Why recalled" section.
To check retrieval quality systematically, use the evaluation endpoint.
Runs and consolidation
How a run's entries are promoted into durable facts, an episode and procedures — and how facts are promoted further to tenant conventions.
Identity and visibility
How credentials bind to agents and end users, and how per-memory visibility decides who can recall, update, share or delete a memory.