Skip to main content

Compactor

Trait Compactor 

Source
pub trait Compactor: WasmCompatSend + WasmCompatSync {
    type Artifact: Into<Message> + Clone + WasmCompatSend + WasmCompatSync + 'static;

    // Required method
    fn compact<'a>(
        &'a self,
        conversation_id: &'a ConversationId,
        evicted: &'a [Message],
        carry_over: Option<&'a Self::Artifact>,
    ) -> WasmBoxedFuture<'a, Result<Self::Artifact, MemoryError>>;
}
Expand description

Derives an artifact from evicted messages for insertion before recent history. Compaction runs inline during loading and delays the next turn.

carry_over contains the previous artifact, if any. Combine it with the evicted messages to preserve earlier context in a rolling summary, or ignore it to summarize only the newly evicted messages.

Delivery watermarks are not persisted across restarts. Implementations with side effects should deduplicate by conversation ID and content hash.

Required Associated Types§

Source

type Artifact: Into<Message> + Clone + WasmCompatSend + WasmCompatSync + 'static

Summary convertible to a history message and clonable for the next compaction’s carry_over.

Required Methods§

Source

fn compact<'a>( &'a self, conversation_id: &'a ConversationId, evicted: &'a [Message], carry_over: Option<&'a Self::Artifact>, ) -> WasmBoxedFuture<'a, Result<Self::Artifact, MemoryError>>

Produce a summary artifact for evicted, optionally combining it with the previous summary in carry_over.

evicted is in original conversation order. Errors are propagated unchanged by composing adapters; pick the MemoryError variant that best describes the failure (MemoryError::Backend for I/O or remote-LLM faults, MemoryError::Internal for invariant breaks, and so on). The adapter does not re-wrap the returned variant.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<C> Compactor for Arc<C>
where C: Compactor + ?Sized,

Source§

type Artifact = <C as Compactor>::Artifact

Source§

fn compact<'a>( &'a self, conversation_id: &'a ConversationId, evicted: &'a [Message], carry_over: Option<&'a Self::Artifact>, ) -> WasmBoxedFuture<'a, Result<Self::Artifact, MemoryError>>

Implementors§