Agent Memory
Concepts

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):

FieldContents
receiptIdThe receipt of this delivery.
blocksMemory blocks visible to the agent. Always included.
userProfileThe end user's profile, when the request names a userId.
platformEntriesPlatform policies and defaults.
tenantFloorsNon-negotiable tenant policies.
tenantEntriesApproved tenant conventions.
workspaceEntriesRanked workspace memory, best match first.
proceduresLearned procedures relevant to the query.
relevantEpisodesSimilar past runs.
fileDocsDocumented files relevant to the query.
sessionSummary, sessionEntriesThe current run's compressed summary and recent entries.
omittedWorkspaceCountMatches dropped to fit the budget. Truncation is never silent.
supersededHiddenCountMatches hidden because a newer memory replaced them.
compilationThe budget, tokens used and per-section included / dropped / tokens. Null in raw mode.
diagnosticsRequest-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 assisted mode.

Assisted vs deterministic

modeBehaviour
deterministicZero generative-model calls on recall. Reproducible. The default (retrieval.mode).
assistedRecall 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_SMALL and both numbers (requestedTokens, requiredTokens).
  • compilation reports 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: true returns them with supersededAt and supersededBy set.
  • asOf slices the store at an instant, on the valid axis (what was true in the world — the default) or the transaction axis (what the system knew), chosen with asOfAxis.

The workspace setting retrieval.hideSuperseded can switch the default off.

Request options

FieldTypeEffect
semanticQuerystringThe natural-language query. Optional — without it you get blocks, profile, policies and session context.
runIdstringThe run this recall belongs to. Session memory and the receipt are tied to it — reuse the task's runId.
userIdstringInclude this user's profile and narrow to their memories.
applicationIdGUIDScope to an application (plus the workspace-wide pool).
topNintCandidate pool size, clamped to 1–100.
tokenBudgetint256–32,000.
minScorenumberAbsolute score floor instead of the adaptive one.
modeassisted | deterministicSee above.
rerankboolfalse skips the reranker, true forces it (assisted only).
tagsobjectNarrow to memories carrying these tag pairs, e.g. {"facet":"auth"}.
includeSupersededboolReturn replaced memories too.
asOf, asOfAxistimestamp, valid | transactionPoint-in-time view.
temporalBefore, temporalAftertimestampOnly memories created before/after this instant.
temporalAnchortimestampPrefer memories created close to this instant.
expandSessions, expandSessionCount, expandSessionWindowbool, int, intReturn whole top-ranked runs (default 5) or a ±N-entry window around each match.
rawboolSkip floor and budget.
explainboolAdd a per-entry explanation and request diagnostics.
overridesobjectPer-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.

On this page