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§
Sourcefn add_message(
&self,
message: &Message,
) -> impl Future<Output = Result<()>> + Send
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".