pub trait ConversationMemory: WasmCompatSend + WasmCompatSync {
// Required methods
fn load<'a>(
&'a self,
conversation_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, MemoryError>> + Send + 'a>>;
fn append<'a>(
&'a self,
conversation_id: &'a str,
messages: Vec<Message>,
) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'a>>;
fn clear<'a>(
&'a self,
conversation_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'a>>;
}Expand description
Re-exports of the core memory abstractions so callers only need a single
dependency on rig-memory for both the trait/backend and the policies.
A persistent conversation history backend.
Implementors store an ordered list of Messages per conversation_id. Rig
invokes ConversationMemory::load before sending a prompt and
ConversationMemory::append after a successful turn.
Implementations should keep append cheap; it runs inline before the agent
returns its response.
Required Methods§
Sourcefn load<'a>(
&'a self,
conversation_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, MemoryError>> + Send + 'a>>
fn load<'a>( &'a self, conversation_id: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, MemoryError>> + Send + 'a>>
Load the full conversation history for conversation_id.
Returns an empty Vec if the conversation has no stored messages.
Sourcefn append<'a>(
&'a self,
conversation_id: &'a str,
messages: Vec<Message>,
) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'a>>
fn append<'a>( &'a self, conversation_id: &'a str, messages: Vec<Message>, ) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'a>>
Append messages to the conversation identified by conversation_id.
Called after a successful agent turn with the user prompt, the assistant response, and any tool-call/tool-result pairs that occurred during the turn.