Skip to main content

ConversationMemory

Trait ConversationMemory 

Source
pub trait ConversationMemory: WasmCompatSend + WasmCompatSync {
    // Required methods
    fn load<'a>(
        &'a self,
        conversation_id: &'a ConversationId,
    ) -> WasmBoxedFuture<'a, Result<Vec<Message>, MemoryError>>;
    fn append<'a>(
        &'a self,
        conversation_id: &'a ConversationId,
        messages: Vec<Message>,
    ) -> WasmBoxedFuture<'a, Result<(), MemoryError>>;
    fn clear<'a>(
        &'a self,
        conversation_id: &'a ConversationId,
    ) -> WasmBoxedFuture<'a, Result<(), MemoryError>>;
}
Expand description

A persistent conversation history backend.

Implementors store an ordered list of Messages per conversation_id. Rig runtimes invoke ConversationMemory::load before sending a prompt and ConversationMemory::append after a successful run.

Appends run inline before the agent returns its response. Load failures prevent model calls; append failures are reported alongside the successful answer without retry. Writes are not transactional or exactly-once: an error may occur after the backend has persisted messages.

Required Methods§

Source

fn load<'a>( &'a self, conversation_id: &'a ConversationId, ) -> 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 ConversationId, 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 ConversationId, ) -> WasmBoxedFuture<'a, Result<(), MemoryError>>

Remove all stored messages for conversation_id.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<M> ConversationMemory for Arc<M>

Source§

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

Source§

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

Source§

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

Source§

impl<M> ConversationMemory for Box<M>

Source§

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

Source§

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

Source§

fn clear<'a>( &'a self, conversation_id: &'a ConversationId, ) -> 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