Skip to main content

ToolResultExtractor

Trait ToolResultExtractor 

Source
pub trait ToolResultExtractor: Send + Sync {
    // Required method
    fn extract<'a>(
        &'a self,
        tool_name: &'a str,
        output: &'a str,
        user_query: &'a str,
    ) -> Pin<Box<dyn Future<Output = Option<ExtractedResult>> + Send + 'a>>;

    // Provided method
    fn extraction_threshold(&self) -> u32 { ... }
}
Expand description

Async semantic extractor for oversized tool results.

Implementations run after structural pruning and can perform heavyweight async work (e.g., calling a fast LLM) to condense large results into task-relevant summaries.

The extractor receives the last user message as context to guide relevance-based extraction.

Required Methods§

Source

fn extract<'a>( &'a self, tool_name: &'a str, output: &'a str, user_query: &'a str, ) -> Pin<Box<dyn Future<Output = Option<ExtractedResult>> + Send + 'a>>

Extract task-relevant information from a tool result.

§Arguments
  • tool_name — The name of the tool that produced this result.
  • output — The (already structurally pruned) output string.
  • user_query — The most recent user message, for relevance guidance.

Return None to skip extraction (keep the structurally-pruned content). The extractor is only called for results exceeding extraction_threshold tokens.

Provided Methods§

Source

fn extraction_threshold(&self) -> u32

Token threshold above which results are offered to the extractor.

Results at or below this size skip semantic extraction entirely. Default: 15 000 tokens (~60 000 chars).

Implementors§