Skip to main content

RecallRequest

Struct RecallRequest 

Source
pub struct RecallRequest {
Show 18 fields pub query: Vec<f32>, pub top_k: usize, pub memory_types: Option<Vec<MemoryType>>, pub agent_id: Option<String>, pub metric: Metric, pub weights: ScoreWeights, pub n_probe: Option<usize>, pub n_rerank: Option<usize>, pub track_access: bool, pub filter: Filter, pub visibility: VisibilitySet, pub max_bytes: Option<usize>, pub keywords: Option<String>, pub text: Option<String>, pub keyword_weight: f32, pub text_keyword_weight: f32, pub bm25_k1: f32, pub bm25_b: f32,
}
Expand description

A retrieval request for Mnemo::recall.

Fields§

§query: Vec<f32>

Query embedding.

§top_k: usize

Maximum results to return.

§memory_types: Option<Vec<MemoryType>>

Restrict to these memory types (None = all types).

§agent_id: Option<String>

Restrict to a single agent’s view: its own memories plus shared ones.

§metric: Metric

Similarity metric.

§weights: ScoreWeights

Multi-signal score weights.

§n_probe: Option<usize>

Index override: partitions to probe (None = index default). Ignored when no ANN index is present.

§n_rerank: Option<usize>

Index override: candidates to rerank (None = index default). Ignored when no ANN index is present.

§track_access: bool

Whether to update each result’s accessed_at and access_count in the catalog. Defaults to true, matching pre-v5 behavior.

Set to false for fully read-only recall — useful for batch scoring, dry-run scoring, or recalls run by introspection tooling (e.g. mnemo about consumers) where you don’t want the score’s own observation to perturb the database. With false, recall does not dirty the catalog and the next flush is a no-op.

§filter: Filter

Phase 12.6 pre-scoring filter: session_id + AND-ed metadata conditions applied before the candidate is scored. Default is Filter::default (no constraints). When the ANN index is on and this filter is selective enough to starve the shortlist below top_k, Phase 12.1’s widen-then-exact-scan logic kicks in so the result still carries up to top_k correct hits.

§visibility: VisibilitySet

13a (13.5): the visibility levels recall returns: public and team by default; private only when asked (RecallRequest::visibility).

§max_bytes: Option<usize>

Phase 12.8 post-scoring budget: stop adding hits once the UTF-8 bytes of their content fields (not the serialized record body) would exceed this many bytes. None (default) means no budget and every hit through top_k is returned. If the top-1 hit is already over budget it is still returned — callers that need an absolute cap should also pre-size top_k.

Counts only the UTF-8 content bytes so the number is stable across the Rust / Python / CLI / MCP surfaces; the JSON or MessagePack envelope is excluded. Roughly 4 bytes per BPE token for English text — a 4 KB budget comfortably holds ~1K tokens.

Observable through RecallResponse::truncated (Mnemo::recall_budgeted): true iff at least one scored hit was dropped by this budget, false otherwise.

§keywords: Option<String>

FMT-9d (Phase 2, v9 files): identifiers or exact terms to match (a version, a PR number, a function name) for hybrid recall. BM25 scores, divided by this query’s best, are added to each candidate’s similarity with weight RecallRequest::keyword_weight before the usual scoring. With an empty query vector (RecallRequest::keywords_only), recall is keyword-only.

Since v0.15 (12.3 step 4), a recall by text is hybrid by default: with keywords None, the request’s RecallRequest::text is used for BM25, so give keywords only for identifiers the question doesn’t contain. Keywords given replace the text. Empty keywords (.keywords("")) opt out: vector-only recall. None on a request with no text is plain vector recall.

§text: Option<String>

12.3 step 4 (v0.15): the query text a recall by text was built from (RecallRequest::from_text sets it). With keywords None it’s also scored with BM25 on a v9 file (hybrid by default); a v8 file, which has no keyword index, ignores it.

§keyword_weight: f32

FMT-9d: weight ε of the normalised BM25 score in hybrid recall (default DEFAULT_KEYWORD_WEIGHT), for keywords given.

§text_keyword_weight: f32

12.3 step 4 (v0.15): the weight when BM25 scores the request’s RecallRequest::text (no keywords given); default DEFAULT_TEXT_KEYWORD_WEIGHT.

§bm25_k1: f32

FMT-9d: BM25 term-frequency saturation k1 (default 1.2).

§bm25_b: f32

FMT-9d: BM25 length normalisation b (default 0.75).

Implementations§

Source§

impl RecallRequest

Source

pub fn new(query: Vec<f32>) -> Self

A request with sensible defaults for a query embedding.

Source

pub fn visibility(self, v: VisibilitySet) -> Self

13a (13.5): the visibility levels to return (private records only when the set includes them).

Source

pub fn keywords_only(keywords: impl Into<String>) -> Self

FMT-9d (v9 files): a keyword-only request: BM25 over keywords (identifiers or exact terms), no query vector, so it works without an embedder.

Source

pub fn keywords(self, text: impl Into<String>) -> Self

FMT-9d (v9 files): add identifiers or exact terms to match (hybrid recall). They replace the request’s text for BM25; "" opts out of keyword scoring. See the keywords field.

Source

pub fn text_keyword_weight(self, w: f32) -> Self

12.3 step 4: the weight of the text’s keyword score when no keywords are given (see RecallRequest::text_keyword_weight).

Source

pub fn keyword_weight(self, w: f32) -> Self

FMT-9d: the weight ε of the keyword score in hybrid recall.

Source

pub fn filter(self, filter: Filter) -> Self

Phase 12.6: attach a pre-scoring filter. See Filter and FilterTerm for term shapes.

Source

pub fn max_bytes(self, n: usize) -> Self

Phase 12.8: cap the total UTF-8 bytes of returned content fields. See RecallRequest::max_bytes.

Source

pub fn from_text(embedder: &dyn Embedder, query_text: &str) -> Result<Self>

Build a request by embedding query_text with the supplied embedder (Phase 3). Since v0.15 it embeds with Embedder::embed_query and keeps the text in RecallRequest::text, so the recall is hybrid by default (see RecallRequest::keywords; .keywords("") opts out). Otherwise the same defaults as new. Fails if the embedder returns an empty vector list or an embedding failure.

Source

pub fn text(self, text: impl Into<String>) -> Self

12.3 step 4: set the query text (see RecallRequest::text), for a caller that embedded it itself.

Source

pub fn top_k(self, k: usize) -> Self

Set the result cap.

Source

pub fn types(self, t: Vec<MemoryType>) -> Self

Restrict to specific memory types.

Source

pub fn agent(self, agent_id: impl Into<String>) -> Self

Restrict to one agent’s view.

Source

pub fn metric(self, metric: Metric) -> Self

Set the similarity metric (default: cosine).

Source

pub fn weights(self, weights: ScoreWeights) -> Self

Replace the multi-signal score weights.

Source

pub fn n_probe(self, n: usize) -> Self

Override the number of IVF partitions probed (accuracy/speed dial).

Source

pub fn n_rerank(self, n: usize) -> Self

Override the number of candidates reranked exactly (accuracy dial).

Source

pub fn track_access(self, track: bool) -> Self

Toggle whether recall updates accessed_at / access_count on the returned memories’ catalog entries (default true). Pass false for a fully read-only recall — see the field doc.

Trait Implementations§

Source§

impl Clone for RecallRequest

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RecallRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V