Skip to main content

MemoryQuery

Struct MemoryQuery 

Source
pub struct MemoryQuery {
    pub text: Option<String>,
    pub category: Option<String>,
    pub tags: Vec<String>,
    pub agent: Option<String>,
    pub agent_prefix: Option<String>,
    pub limit: usize,
    pub memory_type: Option<MemoryType>,
    pub min_strength: Option<f64>,
    pub query_embedding: Option<Vec<f32>>,
    pub max_confidentiality: Option<Confidentiality>,
    pub reinforce: bool,
    pub exact_words: bool,
}
Expand description

Query parameters for recalling memories.

limit controls the maximum number of results returned. A value of 0 means no limit (return all matching entries). This is the default.

Fields§

§text: Option<String>§category: Option<String>§tags: Vec<String>§agent: Option<String>§agent_prefix: Option<String>

Filter entries whose agent field starts with this prefix. Useful for cross-agent recall within a user namespace (e.g. "tg:123" matches "tg:123:assistant", "tg:123:researcher", etc.). Mutually exclusive with agent — if both are set, agent takes precedence.

§limit: usize

Maximum number of results. 0 means unlimited.

§memory_type: Option<MemoryType>

Filter by memory type.

§min_strength: Option<f64>

Minimum strength threshold. Entries below this are excluded.

§query_embedding: Option<Vec<f32>>

Optional query embedding for hybrid (BM25 + vector) retrieval. When present and entries have stored embeddings, cosine similarity is computed and fused with BM25 via Reciprocal Rank Fusion. Populated automatically by EmbeddingMemory::recall().

§max_confidentiality: Option<Confidentiality>

When set, recall excludes entries with confidentiality above this level. None means no restriction (all levels returned).

§reinforce: bool

Whether to reinforce the strength of returned entries on this read (Ebbinghaus reinforcement, +0.2 per access, capped at 1.0).

Defaults to true to preserve historical recall semantics. Set to false for a pure read — useful when surfacing strength to a UI, driving deterministic decay tests, or letting prune_weak_entries observe a freshly-stored low-strength entry without first promoting it above the prune threshold. last_accessed and access_count are still updated regardless.

§exact_words: bool

Opt in to exact-word text matching instead of the default substring (word.contains(token)) semantics.

When true, InMemoryStore::recall short-circuits to entries whose lowercased content / keyword tokens exactly equal at least one query token, looked up via the in-memory inverted index built at store time. Estimated gain at N=10k entries: 12.69 ms → 1–3 ms text-query recall (Phase 8 in tasks/perf-audit-v2-2026-05-07.md).

Trade-off: queries whose tokens are prefixes / substrings of indexed words (“perf” matching “performance”) will no longer match. Default is false — substring semantics preserved; opt-in when callers know their queries are full words. The Postgres path ignores this flag (it doesn’t implement substring matching the same way).

Trait Implementations§

Source§

impl Clone for MemoryQuery

Source§

fn clone(&self) -> MemoryQuery

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 MemoryQuery

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for MemoryQuery

Source§

fn default() -> Self

Returns the “default value” for a type. 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<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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more