pub struct MemoryStore { /* private fields */ }Expand description
Persistent store for agent memories, organized by category into subdirectories. Maintains a MEMORY.md index file.
Implementations§
Source§impl MemoryStore
impl MemoryStore
Sourcepub fn maintenance_report(
&self,
policy: &MemoryMaintenancePolicy,
) -> MemoryMaintenanceReport
pub fn maintenance_report( &self, policy: &MemoryMaintenancePolicy, ) -> MemoryMaintenanceReport
Build a dry-run report of memories that would be archived by the policy.
Sourcepub fn apply_maintenance(
&mut self,
policy: &MemoryMaintenancePolicy,
) -> Result<MemoryMaintenanceReport>
pub fn apply_maintenance( &mut self, policy: &MemoryMaintenancePolicy, ) -> Result<MemoryMaintenanceReport>
Apply a maintenance policy by archiving the report’s candidate memories.
Source§impl MemoryStore
impl MemoryStore
Sourcepub fn query(&self, query: MemoryQuery) -> Vec<MemoryEntry>
pub fn query(&self, query: MemoryQuery) -> Vec<MemoryEntry>
Query memories by metadata. Uses the in-memory cache — no disk I/O.
Sourcepub fn search(&self, query: &str) -> Vec<MemoryEntry>
pub fn search(&self, query: &str) -> Vec<MemoryEntry>
Search memories by keyword — matches name, description, tags, and body. Uses the in-memory cache — no disk I/O.
Sourcepub fn top_by_usage(&self, n: usize) -> Vec<MemoryEntry>
pub fn top_by_usage(&self, n: usize) -> Vec<MemoryEntry>
Get the top N most-used memories for prompt injection.
Sourcepub fn search_relevant(
&self,
query: &str,
limit: usize,
min_relevance: f64,
) -> Vec<MemoryEntry>
pub fn search_relevant( &self, query: &str, limit: usize, min_relevance: f64, ) -> Vec<MemoryEntry>
Score cached memories against a user query and return the top-K by keyword-overlap relevance. Non-deprecated entries only.
min_relevance (0.0-1.0) discards entries whose composite score falls
below the threshold. A value around 0.10 filters out false-positive
matches from very common tokens.
This is the primary method for dynamic memory injection — unlike
query() + MemorySort::Relevance (which sorts by metadata), this
uses the actual content of the user’s prompt to find semantically
relevant memories via simple token overlap.
Source§impl MemoryStore
impl MemoryStore
Sourcepub fn write(&mut self, entry: MemoryEntry) -> Result<()>
pub fn write(&mut self, entry: MemoryEntry) -> Result<()>
Write a memory entry to disk and update the index.
Sourcepub fn upsert(&mut self, entry: MemoryEntry) -> Result<UpsertOutcome>
pub fn upsert(&mut self, entry: MemoryEntry) -> Result<UpsertOutcome>
Write a new memory or merge into an existing one with the same name or description.
Sourcepub fn read(&self, name: &str) -> Option<MemoryEntry>
pub fn read(&self, name: &str) -> Option<MemoryEntry>
Read a memory entry by name.
Sourcepub fn update_status(&mut self, name: &str, status: MemoryStatus) -> Result<()>
pub fn update_status(&mut self, name: &str, status: MemoryStatus) -> Result<()>
Update the status of a memory entry.
Sourcepub fn record_use(&mut self, name: &str) -> Result<()>
pub fn record_use(&mut self, name: &str) -> Result<()>
Record that a memory was explicitly used.