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 Self: 'async_trait,
'life0: 'async_trait,
'life1: '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 Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: '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§
Sourcefn window_size(&self) -> usize
fn window_size(&self) -> usize
How many recent turns this extractor needs.
Provided Methods§
Sourcefn should_extract(&self, window: &[TranscriptTurn]) -> bool
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.
Sourcefn trigger(&self) -> ExtractionTrigger
fn trigger(&self) -> ExtractionTrigger
The trigger mode for this extractor.
Controls when the extractor runs. Default is EveryTurn.
Sourcefn promotion_rules(&self) -> &[FieldPromotion]
fn promotion_rules(&self) -> &[FieldPromotion]
Field promotion rules for this extractor.
When empty, the runtime preserves legacy behavior and auto-flattens top-level non-null fields into state. When non-empty, only these rules can promote raw extraction fields into authoritative state.
Sourcefn 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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: '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.
Sourcefn on_complete(&self) -> Option<OnComplete>
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.