Brain Docs

Reference

Python SDKInstallationHTTP clientWire clientSync vs async
encoderecallforgetencode_vectormemory_listmemory_inspectgraph_fetchlinkunlink
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
Python 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(query: str, max_results: int | None = None, subject: str | None = None,
       scope: str | None = None, include_trace: bool | None = None) -> RecallResult
Handshake credentialstable
recall(request: RecallRequest) -> RecallAnswer
recall_frames(request: RecallRequest) -> list[RecallResponseFrame]

Parameters

ParameterTypeRequired
querystringrequired

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

max_resultsintegeroptional

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.

include_tracebooleanoptional

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

Returns

FieldTypePresence
answer_kindsingle | 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[].memory_idstringalways

The memory's id.

memories[].textstringalways

The stored text, verbatim.

memories[].similarity_scorefloatalways

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[].created_at_unix_nanos64-bit integeralways

Record time.

tracestring

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

Example

answer = brain.recall(query="where does Priya work now?", max_results=5)

if answer.answer_kind == "none":
    return "I don't have anything on that."
if answer.answer_kind == "single":
    return answer.memories[0].text
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
contributing_retrieversRetrieverName[]always

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

fused_scorefloatalways

The score after reciprocal-rank fusion across lanes.

rerank_scorefloat | 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.

salience_initial / access_count / lsn / flags—always
Provenance and bookkeeping.
occurred_at_unix_nanos / consolidated_at_unix_nanos64-bit integer | nullalways

Event time, and when a consolidation absorbed this memory.

edges_out_count / edges_in_countintegeralways
Degree, even when edges were not requested.

Frames

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

FieldTypePresence
is_finalbooleanalways

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

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

RecallBuilder

ParameterTypeRequired
RecallBuilder(cue_text)RecallBuilderrequired
The cue.
.subject(subject_name)RecallBuilderoptional
Anchor on a named subject.
.limit(max_results)RecallBuilderoptional
Note the name: limit, not max_results — the HTTP tier's keyword is max_results.
.confidence(threshold)RecallBuilderoptional
Confidence floor.
.salience(floor)RecallBuilderoptional
Salience floor.
.sessions(sessions: list[int])RecallBuilderoptional
Restrict to these sessions.
.kinds(kinds: list[int])RecallBuilderoptional
Restrict to these memory kinds.
.as_of(as_of_record_time_unix_nanos)RecallBuilderoptional
Read as of a record time.
.edges(include)RecallBuilderoptional
Attach memory edges.
.graph(include)RecallBuilderoptional
Attach typed-graph enrichment.
.text(include)RecallBuilderoptional
Return the stored text.
.trace(trace: bool = True)RecallBuilderoptional
Enable the trace.
.scope(scope: str)RecallBuilderoptional
RecallScope.SPACE or RecallScope.NAMESPACE.
.act_as(namespace, space)RecallBuilderoptional
Read as another space.
.build()RecallRequestrequired
Produces the request, with a fresh request_id.
from brain_db_sdk import RecallBuilder

frames = client.recall_frames(
    RecallBuilder("where does Priya work now?").limit(5).graph(True).trace().build()
)
for f in frames:
    render(f.memories)
    if f.is_final:
        print("verdict:", f.answer_kind)
See also
encodequery_traceHow 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