Skip to main content

ConversationMemory

Trait ConversationMemory 

Source
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§

Source

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.

Source

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.

Source

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>

Source§

fn load<'a>( &'a self, conversation_id: &'a str, ) -> WasmBoxedFuture<'a, Result<Vec<Message>, MemoryError>>

Source§

fn append<'a>( &'a self, conversation_id: &'a str, messages: Vec<Message>, ) -> WasmBoxedFuture<'a, Result<(), MemoryError>>

Source§

fn clear<'a>( &'a self, conversation_id: &'a str, ) -> WasmBoxedFuture<'a, Result<(), MemoryError>>

Source§

impl<M> ConversationMemory for Arc<M>

Source§

fn load<'a>( &'a self, conversation_id: &'a str, ) -> WasmBoxedFuture<'a, Result<Vec<Message>, MemoryError>>

Source§

fn append<'a>( &'a self, conversation_id: &'a str, messages: Vec<Message>, ) -> WasmBoxedFuture<'a, Result<(), MemoryError>>

Source§

fn clear<'a>( &'a self, conversation_id: &'a str, ) -> WasmBoxedFuture<'a, Result<(), MemoryError>>

Implementors§

Source§

impl ConversationMemory for AppendFailingMemory

Available on crate feature test-utils only.
Source§

impl ConversationMemory for CountingMemory

Available on crate feature test-utils only.
Source§

impl ConversationMemory for FailingMemory

Available on crate feature test-utils only.
Source§

impl ConversationMemory for InMemoryConversationMemory