fix: use safe_truncate to truncate charactor (#3263) (#3264)

Signed-off-by: toyamagu2021@gmail.com <toyamagu2021@gmail.com>
This commit is contained in:
toyamagu-2021
2025-07-15 19:34:40 +09:00
committed by GitHub
parent c6225e38d0
commit d3beeace95
13 changed files with 46 additions and 52 deletions
@@ -17,14 +17,14 @@ pub fn process_tool_response(
match content {
Content::Text(text_content) => {
// Check if text exceeds threshold
if text_content.text.len() > LARGE_TEXT_THRESHOLD {
if text_content.text.chars().count() > LARGE_TEXT_THRESHOLD {
// Write to temp file
match write_large_text_to_file(&text_content.text) {
Ok(file_path) => {
// Create a new text content with reference to the file
let message = format!(
"The response returned from the tool call was larger ({} characters) and is stored in the file which you can use other tools to examine or search in: {}",
text_content.text.len(),
text_content.text.chars().count(),
file_path
);
processed_contents.push(Content::text(message));