Skip to main content

ToolResultCacher

Trait ToolResultCacher 

Source
pub trait ToolResultCacher: Send + Sync {
    // Required method
    fn cache(&self, tool_name: &str, content: &str) -> Option<CachedResult>;

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

Caches oversized tool results out-of-context.

Implementations store the full content somewhere (file, KV store, database, …) and return a compact summary for the conversation. The summary should tell the LLM how to retrieve slices (e.g. via a result_cache tool with a ref argument).

Required Methods§

Source

fn cache(&self, tool_name: &str, content: &str) -> Option<CachedResult>

Store content and return a summary for the conversation.

Called only when the (already-processed) result exceeds inline_threshold tokens.

Return None to fall back to keeping the content inline (e.g. if storage fails).

Provided Methods§

Source

fn inline_threshold(&self) -> u32

Token threshold above which results are offered to the cacher.

Results at or below this size stay inline in the conversation. Default: 2 000 tokens (~8 000 chars).

Implementors§