minor
This commit is contained in:
@@ -739,7 +739,7 @@ The tool will execute immediately and you'll receive the result (success or erro
|
|||||||
},
|
},
|
||||||
Tool {
|
Tool {
|
||||||
name: "write_file".to_string(),
|
name: "write_file".to_string(),
|
||||||
description: "Write content to a file (creates or overwrites)".to_string(),
|
description: "Write content to a file (creates or overwrites). You MUST provide all arguments".to_string(),
|
||||||
input_schema: json!({
|
input_schema: json!({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -789,7 +789,7 @@ The tool will execute immediately and you'll receive the result (success or erro
|
|||||||
"properties": {
|
"properties": {
|
||||||
"summary": {
|
"summary": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "A detailed summary of what was accomplished"
|
"description": "A detailed summary in markdown of what was accomplished"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["summary"]
|
"required": ["summary"]
|
||||||
@@ -1000,7 +1000,11 @@ The tool will execute immediately and you'll receive the result (success or erro
|
|||||||
|
|
||||||
// Track tool call metrics
|
// Track tool call metrics
|
||||||
let tool_success = !tool_result.contains("❌");
|
let tool_success = !tool_result.contains("❌");
|
||||||
self.tool_call_metrics.push((tool_call.tool.clone(), exec_duration, tool_success));
|
self.tool_call_metrics.push((
|
||||||
|
tool_call.tool.clone(),
|
||||||
|
exec_duration,
|
||||||
|
tool_success,
|
||||||
|
));
|
||||||
|
|
||||||
// Display tool execution result with proper indentation
|
// Display tool execution result with proper indentation
|
||||||
let output_lines: Vec<&str> = tool_result.lines().collect();
|
let output_lines: Vec<&str> = tool_result.lines().collect();
|
||||||
@@ -1107,7 +1111,10 @@ The tool will execute immediately and you'll receive the result (success or erro
|
|||||||
debug!("Printing filtered content: '{}'", filtered_content);
|
debug!("Printing filtered content: '{}'", filtered_content);
|
||||||
print!("{}", filtered_content);
|
print!("{}", filtered_content);
|
||||||
let _ = io::stdout().flush(); // Force immediate output
|
let _ = io::stdout().flush(); // Force immediate output
|
||||||
debug!("Flushed {} characters to stdout", filtered_content.len());
|
debug!(
|
||||||
|
"Flushed {} characters to stdout",
|
||||||
|
filtered_content.len()
|
||||||
|
);
|
||||||
current_response.push_str(&filtered_content);
|
current_response.push_str(&filtered_content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1226,7 +1233,11 @@ The tool will execute immediately and you'll receive the result (success or erro
|
|||||||
"write_file" => {
|
"write_file" => {
|
||||||
debug!("Processing write_file tool call");
|
debug!("Processing write_file tool call");
|
||||||
debug!("Raw tool_call.args: {:?}", tool_call.args);
|
debug!("Raw tool_call.args: {:?}", tool_call.args);
|
||||||
debug!("Args as JSON: {}", serde_json::to_string(&tool_call.args).unwrap_or_else(|_| "failed to serialize".to_string()));
|
debug!(
|
||||||
|
"Args as JSON: {}",
|
||||||
|
serde_json::to_string(&tool_call.args)
|
||||||
|
.unwrap_or_else(|_| "failed to serialize".to_string())
|
||||||
|
);
|
||||||
|
|
||||||
let file_path = tool_call.args.get("file_path");
|
let file_path = tool_call.args.get("file_path");
|
||||||
let content = tool_call.args.get("content");
|
let content = tool_call.args.get("content");
|
||||||
@@ -1454,14 +1465,17 @@ fn filter_json_tool_calls(content: &str) -> String {
|
|||||||
let trimmed = content.trim();
|
let trimmed = content.trim();
|
||||||
|
|
||||||
// Check for partial patterns that might indicate the start of a JSON tool call
|
// Check for partial patterns that might indicate the start of a JSON tool call
|
||||||
if trimmed.starts_with(r#"{"tool"#) ||
|
if trimmed.starts_with(r#"{"tool"#)
|
||||||
trimmed.starts_with(r#"{ "tool"#) ||
|
|| trimmed.starts_with(r#"{ "tool"#)
|
||||||
trimmed.starts_with(r#"{"#) && (trimmed.contains("tool") || trimmed.contains("args")) ||
|
|| trimmed.starts_with(r#"{"#) && (trimmed.contains("tool") || trimmed.contains("args"))
|
||||||
trimmed.contains(r#""tool":"#) ||
|
|| trimmed.contains(r#""tool":"#)
|
||||||
trimmed.contains(r#""args":"#) ||
|
|| trimmed.contains(r#""args":"#)
|
||||||
trimmed.contains(r#"file_path"#) ||
|
|| trimmed.contains(r#"file_path"#)
|
||||||
trimmed.contains(r#"command"#) ||
|
|| trimmed.contains(r#"command"#)
|
||||||
(trimmed.starts_with('{') && trimmed.len() < 50 && (trimmed.contains("tool") || trimmed.contains("args"))) {
|
|| (trimmed.starts_with('{')
|
||||||
|
&& trimmed.len() < 50
|
||||||
|
&& (trimmed.contains("tool") || trimmed.contains("args")))
|
||||||
|
{
|
||||||
// This looks like part of a JSON tool call, suppress it
|
// This looks like part of a JSON tool call, suppress it
|
||||||
"".to_string()
|
"".to_string()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user