pub trait ConversationMemory: WasmCompatSend + WasmCompatSync {
// Required methods
fn load<'a>(
&'a self,
conversation_id: &'a str,
) -> WasmBoxedFuture<'a, Result<Vec<Message>, MemoryError>>;
fn append<'a>(
&'a self,
conversation_id: &'a str,
messages: Vec<Message>,
) -> WasmBoxedFuture<'a, Result<(), MemoryError>>;
fn clear<'a>(
&'a self,
conversation_id: &'a str,
) -> WasmBoxedFuture<'a, Result<(), MemoryError>>;
}Expand description
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,
) -> WasmBoxedFuture<'a, Result<Vec<Message>, MemoryError>>
fn load<'a>( &'a self, conversation_id: &'a str, ) -> WasmBoxedFuture<'a, Result<Vec<Message>, MemoryError>>
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>,
) -> WasmBoxedFuture<'a, Result<(), MemoryError>>
fn append<'a>( &'a self, conversation_id: &'a str, messages: Vec<Message>, ) -> WasmBoxedFuture<'a, Result<(), MemoryError>>
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.
Sourcefn clear<'a>(
&'a self,
conversation_id: &'a str,
) -> WasmBoxedFuture<'a, Result<(), MemoryError>>
fn clear<'a>( &'a self, conversation_id: &'a str, ) -> WasmBoxedFuture<'a, Result<(), MemoryError>>
Remove all stored messages for conversation_id.
Implementations on Foreign Types§
Source§impl<M> ConversationMemory for Box<M>where
M: ConversationMemory + ?Sized,
impl<M> ConversationMemory for Box<M>where
M: ConversationMemory + ?Sized,
fn load<'a>( &'a self, conversation_id: &'a str, ) -> WasmBoxedFuture<'a, Result<Vec<Message>, MemoryError>>
fn append<'a>( &'a self, conversation_id: &'a str, messages: Vec<Message>, ) -> WasmBoxedFuture<'a, Result<(), MemoryError>>
fn clear<'a>( &'a self, conversation_id: &'a str, ) -> WasmBoxedFuture<'a, Result<(), MemoryError>>
Source§impl<M> ConversationMemory for Arc<M>where
M: ConversationMemory + ?Sized,
impl<M> ConversationMemory for Arc<M>where
M: ConversationMemory + ?Sized,
fn load<'a>( &'a self, conversation_id: &'a str, ) -> WasmBoxedFuture<'a, Result<Vec<Message>, MemoryError>>
fn append<'a>( &'a self, conversation_id: &'a str, messages: Vec<Message>, ) -> WasmBoxedFuture<'a, Result<(), MemoryError>>
fn clear<'a>( &'a self, conversation_id: &'a str, ) -> WasmBoxedFuture<'a, Result<(), MemoryError>>
Implementors§
impl ConversationMemory for AppendFailingMemory
Available on crate feature
test-utils only.impl ConversationMemory for CountingMemory
Available on crate feature
test-utils only.impl ConversationMemory for FailingMemory
Available on crate feature
test-utils only.