Skip to main content

MemoryFacade

Trait MemoryFacade 

Source
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

  • remember stores a message and returns its stable ID.
  • recall performs a best-effort similarity search; empty results are valid.
  • summarize returns a textual summary of the conversation so far.
  • compact reduces context size to within ctx.token_budget.

Implementations must be Send + Sync to support Arc<dyn MemoryFacade> usage.

Required Methods§

Source

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.

Source

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.

Source

async fn summarize( &self, conv_id: ConversationId, ) -> Result<String, MemoryError>

Produce a textual summary of conv_id.

§Errors

Returns MemoryError if summarization fails.

Source

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.

Implementors§