Truncate a tool result to [`MAX_TOOL_RESULT_BYTES`].
(s: &str)
| 1191 | |
| 1192 | /// Truncate a tool result to [`MAX_TOOL_RESULT_BYTES`]. |
| 1193 | fn truncate_result(s: &str) -> String { |
| 1194 | if s.len() <= MAX_TOOL_RESULT_BYTES { |
| 1195 | s.to_string() |
| 1196 | } else { |
| 1197 | let end = truncate_to_char_boundary(s, MAX_TOOL_RESULT_BYTES); |
| 1198 | format!("{}\n\n... truncated ({} bytes total)", &s[..end], s.len()) |
| 1199 | } |
| 1200 | } |
| 1201 | |
| 1202 | /// Generate a short preview for [`ToolTraceEntry`]. |
| 1203 | fn preview(s: &str) -> String { |