pub fn truncate_tool_output_at(output: &str, max_chars: usize) -> StringExpand description
Truncate tool output that exceeds max_chars using a head+tail split.
Preserves the first and last max_chars / 2 characters and inserts a truncation
marker in the middle. Both boundaries are snapped to valid UTF-8 character boundaries.
ยงExample
use zeph_tools::executor::truncate_tool_output_at;
let long = "a".repeat(200);
let truncated = truncate_tool_output_at(&long, 100);
assert!(truncated.contains("truncated"));
assert!(truncated.len() < long.len());