TurnExtractor

Trait TurnExtractor 

Source
pub trait TurnExtractor: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn window_size(&self) -> usize;
    fn extract<'life0, 'life1, 'async_trait>(
        &'life0 self,
        window: &'life1 [TranscriptTurn],
    ) -> Pin<Box<dyn Future<Output = Result<Value, LlmError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn should_extract(&self, window: &[TranscriptTurn]) -> bool { ... }
    fn trigger(&self) -> ExtractionTrigger { ... }
    fn promotion_rules(&self) -> &[FieldPromotion] { ... }
    fn extract_with_state<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        window: &'life1 [TranscriptTurn],
        state: &'life2 State,
    ) -> Pin<Box<dyn Future<Output = Result<Value, LlmError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait { ... }
    fn on_complete(&self) -> Option<OnComplete> { ... }
}
Expand description

Trait for between-turn extraction from transcript windows.

Implementations receive a window of recent transcript turns and produce a structured JSON value. The processor stores the result in State under the extractor’s name.

Required Methods§

Source

fn name(&self) -> &str

Name of this extractor (used as the State key).

Source

fn window_size(&self) -> usize

How many recent turns this extractor needs.

Source

fn extract<'life0, 'life1, 'async_trait>( &'life0 self, window: &'life1 [TranscriptTurn], ) -> Pin<Box<dyn Future<Output = Result<Value, LlmError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Extract structured data from the transcript window.

Provided Methods§

Source

fn should_extract(&self, window: &[TranscriptTurn]) -> bool

Whether this extractor should run for the current turn.

Override to skip extraction on trivial turns (e.g., short utterances, turns without user speech). Default returns true (always extract).

This is checked before launching the async extraction, so returning false avoids an LLM round-trip entirely.

Source

fn trigger(&self) -> ExtractionTrigger

The trigger mode for this extractor.

Controls when the extractor runs. Default is EveryTurn.

Source

fn promotion_rules(&self) -> &[FieldPromotion]

Field promotion rules for this extractor.

When empty, the runtime auto-flattens every top-level non-null field of the extraction into state under the field’s own name. When non-empty, only these rules can promote raw extraction fields into authoritative state.

Source

fn extract_with_state<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, window: &'life1 [TranscriptTurn], state: &'life2 State, ) -> Pin<Box<dyn Future<Output = Result<Value, LlmError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Extract with access to session State — for extractors whose sources bind arguments from State (e.g. async fetch/agent resolvers).

The default delegates to extract, so transcript-only extractors need not implement it. The pipeline always calls this method.

Source

fn on_complete(&self) -> Option<OnComplete>

An optional agent to run when this extractor’s results land in state — the on_complete(dispatch(agent)) effect. Fired by the pipeline after promotion, only when the extractor produced a non-empty object.

Implementors§