MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / truncate_result

Function truncate_result

atomic-repository/src/ai/tools.rs:1193–1200  ·  view source on GitHub ↗

Truncate a tool result to [`MAX_TOOL_RESULT_BYTES`].

(s: &str)

Source from the content-addressed store, hash-verified

1191
1192/// Truncate a tool result to [`MAX_TOOL_RESULT_BYTES`].
1193fn 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`].
1203fn preview(s: &str) -> String {

Callers 3

run_tool_loopFunction · 0.85

Calls 2

lenMethod · 0.45