MCPcopy Create free account
hub / github.com/AI45Lab/Code / truncate_tool_output_with_artifact

Function truncate_tool_output_with_artifact

core/src/tools/mod.rs:71–97  ·  view source on GitHub ↗
(
    tool_name: &str,
    output: &str,
)

Source from the content-addressed store, hash-verified

69}
70
71pub(crate) fn truncate_tool_output_with_artifact(
72 tool_name: &str,
73 output: &str,
74) -> TruncatedToolOutput {
75 if output.len() <= MAX_OUTPUT_SIZE {
76 return TruncatedToolOutput {
77 content: output.to_string(),
78 artifact: None,
79 };
80 }
81
82 let shown = truncate_utf8(output, MAX_OUTPUT_SIZE);
83 let artifact = tool_output_artifact(tool_name, output, shown.len());
84 let artifact_uri = artifact.artifact_uri.clone();
85 let content = format!(
86 "{}\n\n[tool output truncated: showing the first {} of {} bytes. Full output artifact: {}. Use narrower arguments such as offset/limit or filtering when possible.]",
87 shown,
88 shown.len(),
89 output.len(),
90 artifact_uri,
91 );
92
93 TruncatedToolOutput {
94 content,
95 artifact: Some(artifact),
96 }
97}
98
99pub(crate) fn tool_output_artifact(
100 tool_name: &str,

Calls 4

tool_output_artifactFunction · 0.85
truncate_utf8Function · 0.50
lenMethod · 0.45
cloneMethod · 0.45