Truncate a tool result to [`MAX_TOOL_RESULT_BYTES`].
(s: &str)
| 1149 | |
| 1150 | /// Truncate a tool result to [`MAX_TOOL_RESULT_BYTES`]. |
| 1151 | fn truncate_result(s: &str) -> String { |
| 1152 | if s.len() <= MAX_TOOL_RESULT_BYTES { |
| 1153 | s.to_string() |
| 1154 | } else { |
| 1155 | let truncated = &s[..MAX_TOOL_RESULT_BYTES]; |
| 1156 | format!("{truncated}\n\n... truncated ({} bytes total)", s.len()) |
| 1157 | } |
| 1158 | } |
| 1159 | |
| 1160 | /// Generate a short preview for [`ToolTraceEntry`]. |
| 1161 | fn preview(s: &str) -> String { |