pub trait MemoryFacade: Send + Sync {
// Required methods
async fn remember(
&self,
entry: MemoryEntry,
) -> Result<MessageId, MemoryError>;
async fn recall(
&self,
query: &str,
limit: usize,
) -> Result<Vec<MemoryMatch>, MemoryError>;
async fn summarize(
&self,
conv_id: ConversationId,
) -> Result<String, MemoryError>;
async fn compact(
&self,
ctx: &CompactionContext,
) -> Result<CompactionResult, MemoryError>;
}Expand description
Narrow read/write interface over a memory backend.
Implement this trait to provide an alternative backend for unit testing
(see InMemoryFacade) or future agent refactoring.
§Contract
rememberstores a message and returns its stable ID.recallperforms a best-effort similarity search; empty results are valid.summarizereturns a textual summary of the conversation so far.compactreduces context size to withinctx.token_budget.
Implementations must be Send + Sync to support Arc<dyn MemoryFacade> usage.
Required Methods§
Sourceasync fn remember(&self, entry: MemoryEntry) -> Result<MessageId, MemoryError>
async fn remember(&self, entry: MemoryEntry) -> Result<MessageId, MemoryError>
Store a memory entry and return its ID.
§Errors
Returns MemoryError if the backend fails to persist the entry.
Sourceasync fn recall(
&self,
query: &str,
limit: usize,
) -> Result<Vec<MemoryMatch>, MemoryError>
async fn recall( &self, query: &str, limit: usize, ) -> Result<Vec<MemoryMatch>, MemoryError>
Retrieve the most relevant entries for query, up to limit results.
§Errors
Returns MemoryError if the recall query fails.
Sourceasync fn summarize(
&self,
conv_id: ConversationId,
) -> Result<String, MemoryError>
async fn summarize( &self, conv_id: ConversationId, ) -> Result<String, MemoryError>
Sourceasync fn compact(
&self,
ctx: &CompactionContext,
) -> Result<CompactionResult, MemoryError>
async fn compact( &self, ctx: &CompactionContext, ) -> Result<CompactionResult, MemoryError>
Compact a conversation to fit within the token budget.
§Errors
Returns MemoryError if compaction fails.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.