Skip to main content

Memory

Trait Memory 

Source
pub trait Memory: Send + Sync {
    // Required methods
    fn add_message(
        &self,
        message: &Message,
    ) -> impl Future<Output = Result<()>> + Send;
    fn get_messages(&self) -> impl Future<Output = Result<Vec<Message>>> + Send;
    fn clear(&self) -> impl Future<Output = Result<()>> + Send;
}
Expand description

Trait for conversation memory backends. Stores and retrieves messages for agent context.

Required Methods§

Source

fn add_message( &self, message: &Message, ) -> impl Future<Output = Result<()>> + Send

Appends a message to the history. Order is preserved.

Takes a borrow so callers that keep the message (the agent runner appends it to its working log after persisting) don’t clone it per iteration. Backends that store owned messages clone internally; serializing backends (Redis, SQLite) never need ownership at all.

Source

fn get_messages(&self) -> impl Future<Output = Result<Vec<Message>>> + Send

Returns all stored messages in order. Used to build context for the model.

Source

fn clear(&self) -> impl Future<Output = Result<()>> + Send

Removes all messages. Use when starting a new conversation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§