Skip to main content

DemotionHook

Trait DemotionHook 

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

Receives messages removed from active history during ConversationMemory::load. Hooks are awaited inline, so their latency delays the next turn.

Implementations must be idempotent on (conversation_id, messages). Adapter delivery watermarks are not persisted; restarts or newly constructed adapters may redeliver messages. Durable hooks should deduplicate with a stable key such as a conversation ID and content hash.

Required Methods§

Source

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

Receive messages that were demoted out of the active window for conversation_id.

messages are in original conversation order. Errors are propagated as MemoryError::Backend by the composing adapter.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<H> DemotionHook for Arc<H>
where H: DemotionHook + ?Sized,

Source§

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

Implementors§