Brain Docs

Reference

Rust SDKInstallationHTTP clientWire client
encoderecallforgetencode_vectormemory_listmemory_inspectgraph_fetchlinkunlink
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
Rust 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
async fn recall(&self, input: &RecallInput) -> Result<RecallResult, BrainHttpError>
Handshake credentialstable
async fn recall(&self, request: &RecallRequest) -> Result<RecallAnswer>
async fn recall_frames(&self, request: &RecallRequest) -> Result<Vec<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

let answer = brain
    .recall(&RecallInput { query: "where does Priya work now?".into(), max_results: Some(5), ..Default::default() })
    .await?;

match answer.answer_kind.as_str() {
    "none" => "I don't have anything on that.".to_string(),
    "single" => answer.memories[0].text.clone(),
    _ => 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

use brain_db_sdk::RecallBuilder;

let request = RecallBuilder::new("where does Priya work now?")
    .max_results(5)
    .graph(true)
    .trace(true)
    .build();

let frames = client.recall_frames(&request).await?;
for f in &frames {
    render(&f.memories);
    if f.is_final {
        println!("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