Skip to main content

post_process_tool_results

Function post_process_tool_results 

Source
pub fn post_process_tool_results(
    messages: &mut Vec<Message>,
    tool_count: usize,
    current_tool_name: &str,
    context_window: usize,
)
Expand description

Apply truncation to all tool result messages in the last tool_count messages of the conversation.

Two-pass: first per-result truncation, then per-turn budget enforcement. Per-turn budget = 1/4 of context window (max 16K chars). If all results in this turn exceed that, aggressively shrink the largest results.