Skip to main content

Summarizer

Trait Summarizer 

Source
pub trait Summarizer: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn summarize<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        chunks: &'life1 [MemoryChunk],
        ctx: &'life2 SummaryContext,
    ) -> Pin<Box<dyn Future<Output = SummarizerResult<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

The summarizer trait. Object-safe.

Implementations MUST be Send + Sync because the provider may share a single summarizer across tokio tasks (e.g. the cron sweeper and the embedded agent calling summarize_session in parallel).

Required Methods§

Source

fn name(&self) -> &str

Human-readable identifier for the summarizer (e.g. "anthropic:claude-haiku-4-5", "ollama:llama3.2:3b-instruct-q4_K_M", "mock"). Used for tracing/diagnostics; not parsed by the caller.

Source

fn summarize<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, chunks: &'life1 [MemoryChunk], ctx: &'life2 SummaryContext, ) -> Pin<Box<dyn Future<Output = SummarizerResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Produce a summary string for the given chunks. Implementations should respect SummaryContext::max_words when set and produce neutral past-tense prose.

Implementations MUST return SummarizerError::NoInput when chunks is empty. The provider relies on this to skip writing a JobSummary for sessions that have no member chunks.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§