suppress printout of final_output
This commit is contained in:
@@ -1276,36 +1276,39 @@ The tool will execute immediately and you'll receive the result (success or erro
|
|||||||
// Execute the tool with formatted output
|
// Execute the tool with formatted output
|
||||||
println!(); // New line before tool execution
|
println!(); // New line before tool execution
|
||||||
|
|
||||||
// Tool call header
|
// Skip printing tool call details for final_output
|
||||||
println!("┌─ {}", tool_call.tool);
|
if tool_call.tool != "final_output" {
|
||||||
if let Some(args_obj) = tool_call.args.as_object() {
|
// Tool call header
|
||||||
for (key, value) in args_obj {
|
println!("┌─ {}", tool_call.tool);
|
||||||
let value_str = match value {
|
if let Some(args_obj) = tool_call.args.as_object() {
|
||||||
serde_json::Value::String(s) => {
|
for (key, value) in args_obj {
|
||||||
if tool_call.tool == "shell" && key == "command" {
|
let value_str = match value {
|
||||||
if let Some(first_line) = s.lines().next() {
|
serde_json::Value::String(s) => {
|
||||||
if s.lines().count() > 1 {
|
if tool_call.tool == "shell" && key == "command" {
|
||||||
format!("{}...", first_line)
|
if let Some(first_line) = s.lines().next() {
|
||||||
|
if s.lines().count() > 1 {
|
||||||
|
format!("{}...", first_line)
|
||||||
|
} else {
|
||||||
|
first_line.to_string()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
first_line.to_string()
|
s.clone()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s.clone()
|
if s.len() > 100 {
|
||||||
}
|
format!("{}...", &s[..100])
|
||||||
} else {
|
} else {
|
||||||
if s.len() > 100 {
|
s.clone()
|
||||||
format!("{}...", &s[..100])
|
}
|
||||||
} else {
|
|
||||||
s.clone()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
_ => value.to_string(),
|
||||||
_ => value.to_string(),
|
};
|
||||||
};
|
println!("│ {}: {}", key, value_str);
|
||||||
println!("│ {}: {}", key, value_str);
|
}
|
||||||
}
|
}
|
||||||
|
println!("├─ output:");
|
||||||
}
|
}
|
||||||
println!("├─ output:");
|
|
||||||
|
|
||||||
let exec_start = Instant::now();
|
let exec_start = Instant::now();
|
||||||
let tool_result = self.execute_tool(&tool_call).await?;
|
let tool_result = self.execute_tool(&tool_call).await?;
|
||||||
@@ -1321,23 +1324,25 @@ The tool will execute immediately and you'll receive the result (success or erro
|
|||||||
));
|
));
|
||||||
|
|
||||||
// Display tool execution result with proper indentation
|
// Display tool execution result with proper indentation
|
||||||
let output_lines: Vec<&str> = tool_result.lines().collect();
|
if tool_call.tool != "final_output" {
|
||||||
const MAX_LINES: usize = 5;
|
let output_lines: Vec<&str> = tool_result.lines().collect();
|
||||||
|
const MAX_LINES: usize = 5;
|
||||||
|
|
||||||
if output_lines.len() <= MAX_LINES {
|
if output_lines.len() <= MAX_LINES {
|
||||||
for line in output_lines {
|
for line in output_lines {
|
||||||
println!("│ {}", line);
|
println!("│ {}", line);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for line in output_lines.iter().take(MAX_LINES) {
|
||||||
|
println!("│ {}", line);
|
||||||
|
}
|
||||||
|
let hidden_count = output_lines.len() - MAX_LINES;
|
||||||
|
println!(
|
||||||
|
"│ ... ({} more line{} hidden)",
|
||||||
|
hidden_count,
|
||||||
|
if hidden_count == 1 { "" } else { "s" }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
for line in output_lines.iter().take(MAX_LINES) {
|
|
||||||
println!("│ {}", line);
|
|
||||||
}
|
|
||||||
let hidden_count = output_lines.len() - MAX_LINES;
|
|
||||||
println!(
|
|
||||||
"│ ... ({} more line{} hidden)",
|
|
||||||
hidden_count,
|
|
||||||
if hidden_count == 1 { "" } else { "s" }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if this was a final_output tool call
|
// Check if this was a final_output tool call
|
||||||
@@ -1355,10 +1360,12 @@ The tool will execute immediately and you'll receive the result (success or erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Closure marker with timing
|
// Closure marker with timing
|
||||||
println!("└─ ⚡️ {}", Self::format_duration(exec_duration));
|
if tool_call.tool != "final_output" {
|
||||||
println!();
|
println!("└─ ⚡️ {}", Self::format_duration(exec_duration));
|
||||||
print!("🤖 ");
|
println!();
|
||||||
io::stdout().flush()?;
|
print!("🤖 ");
|
||||||
|
io::stdout().flush()?;
|
||||||
|
}
|
||||||
|
|
||||||
// Add the tool call and result to the context window
|
// Add the tool call and result to the context window
|
||||||
// Only include the text content if it's not already in full_response
|
// Only include the text content if it's not already in full_response
|
||||||
|
|||||||
Reference in New Issue
Block a user