Brain Docs

Reference

TypeScript SDKInstallationHTTP clientWire client
encoderecallforgetencodeVectormemoryListmemoryInspectgraphFetchlinkunlink
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
TypeScript SDKMemoryrecall

recall

Retrieve memories for a cue — the Single / Many / None answer shape, scope, and the retrieval trace.

PURPOSE

recall is Brain's read verb. It takes a cue in natural language and returns the memories that answer it, together with a membership verdict — one answer, several, or none. It is not a query language; the cue is embedded and run through the retrievers.

POST/v1/recallBearer API keystable
recall(input: RecallInput): Promise<RecallResult>
Handshake credentialstable
recall(request: RecallRequest): Promise<RecallAnswer>
recallFrames(request: RecallRequest): Promise<RecallResponseFrame[]>

Parameters

ParameterTypeRequired
querystringrequired

The cue. A question, a phrase, or a sentence. On the wire this field is called cueText.

maxResultsintegeroptional

Cap on returned memories. The default is the server's; TopKOutOfRange if it exceeds the shard's ceiling.

subjectstringoptional

Bias retrieval toward a named subject. Pass the entity's canonical name; it anchors the graph retriever rather than filtering the result.

scope"space" | "namespace"optional

How wide to read. space — the default — reads the caller's own space. namespace fans out across every space in the caller's namespace and merges the hits. Case-insensitive; any other value is rejected, not quietly narrowed to the default.

includeTracebooleanoptional

Return Brain's read pipeline alongside the hits. See the warning below for its cost.

Returns

FieldTypePresence
answerKindsingle | many | nonealways

The membership verdict. single — one memory answers the cue. many — several do and the caller must choose or summarise. none — Brain has nothing. Branch on this before reading the hits.

memoriesMemoryHit[]always

The hits, ordered best first. Empty when the verdict is none.

memories[].memoryIdstringalways

The memory's id.

memories[].textstringalways

The stored text, verbatim.

memories[].similarityScorefloatalways

Distance to the cue, after fusion.

memories[].confidencefloatalways

Confidence in the memory's content — not in the match.

memories[].saliencefloatalways

Current salience, after decay.

memories[].kindintegeralways

0 episodic, 1 semantic, 2 consolidated.

memories[].createdAtUnixNanos64-bit integeralways

Record time.

tracestring

Present only when a trace was requested and the server supports it.

Example

const answer = await brain.recall({ query: "where does Priya work now?", maxResults: 5 });

switch (answer.answerKind) {
  case "none":   return "I don't have anything on that.";
  case "single": return answer.memories[0]!.text;
  case "many":   return summarise(answer.memories);
}

recall never fabricates

When Brain holds nothing that answers the cue, the hit list is empty and the verdict is none. There is no generated fallback and no nearest-miss padding. A caller that treats "no hits" as a failure will report outages that are really silences.

The two tiers spell the verdict differently

The wire AnswerKind is Single / Many / None; the HTTP one is single / many / none. Code that switches on the string and is moved between tiers falls through every case silently. The SDK does not normalise them, because the wire value is what the server sent.

The retrieval trace

A trace returns the read pipeline as text: which retrievers ran, how their results were fused, what the filter chain dropped. It is the tool for "why did I get this answer".

The trace does not scale with maxResults

It reports every candidate each lane considered, so it grows with the size of the space, not with the number of hits you asked for. A three-hit recall over roughly 700 memories measured 121 KB. Leave it off in hot paths; it costs nothing when off.

The wire hit

The wire's MemoryResult carries the retrieval evidence the HTTP tier flattens away:

FieldTypePresence
contributingRetrieversRetrieverName[]always

Which lanes found this memory — the per-hit answer to "why is this here".

fusedScorefloatalways

The score after reciprocal-rank fusion across lanes.

rerankScorefloat | nullalways

The cross-encoder's score, or null — which is the normal value, because the reranker ships disabled. See Policies.

edgesEdgeView[] | nullalways
Memory edges, when requested.
graphGraphEnrichment | nullalways

Entities, statements and relations behind the hit, when requested.

salienceInitial / accessCount / lsn / flags—always
Provenance and bookkeeping.
occurredAtUnixNanos / consolidatedAtUnixNanos64-bit integer | nullalways

Event time, and when a consolidation absorbed this memory.

edgesOutCount / edgesInCountintegeralways
Degree, even when edges were not requested.

Frames

The frame-level form returns the stream unconcatenated, for progressive rendering:

FieldTypePresence
isFinalbooleanalways

true on the last frame. Its verdict is the one for the whole read; earlier frames' is provisional.

cumulativeCountintegeralways
Memories delivered so far.
estimatedRemaininginteger | nullalways
The server's estimate, or null when it will not guess.

RecallBuilder

ParameterTypeRequired
new RecallBuilder(cueText)RecallBuilderrequired
The cue.
.subject(name)thisoptional
Anchor on a named subject. Default "".
.maxResults(n)thisoptional
Default 10.
.confidence(threshold)thisoptional
Drop hits below this confidence. Default 0.
.salience(floor)thisoptional
Drop hits below this salience. Default 0.
.sessions(sessions: bigint[])thisoptional
Restrict to these sessions.
.kinds(kinds: MemoryKindWire[])thisoptional
Restrict to these memory kinds.
.asOf(recordTimeUnixNanos: bigint)thisoptional
Read the space as it stood at that record time.
.edges(include)thisoptional
Attach memory edges. Default true.
.graph(include)thisoptional
Attach typed-graph enrichment. Default false.
.text(include)thisoptional
Return the stored text. Default true.
.trace(enable?)thisoptional
Default false; no argument means true.
.scope(scope: RecallScopeWire)thisoptional
"Space" (default) or "Namespace" — capitalised on the wire.
.actAs(namespace, space)thisoptional
Read as another space.
.build()RecallRequestrequired
Produces the request, with a fresh requestId.
See also
encodequeryTraceHow recall decides

Was this page helpful?

encode

Store a memory from text — the write verb, its wait modes, and the deduplication result.

forget

Remove a memory — the soft tombstone, the hard zero, and why a repeat call is safe.

On this page

ParametersReturnsExampleThe retrieval traceThe wire hitFramesRecallBuilder
Suggest an editOpen in Playground