From 0ef2b709b5ec2d44fc947a8b96572f66ee8b3bc9 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 15 Nov 2026 18:31:16 +0100 Subject: 0.7.1: drop argument-less tool calls, print each command once - a name+no-arguments placeholder is removed before the assistant message is recorded, instead of prompting for an empty command - the bash prompt shows the command; the tool line shows only the name - the edit prompt no longer repeats the path already shown above --- src/agent.rs | 15 ++++++++++++++- src/tools/mod.rs | 13 +++++++++++++ src/ui.rs | 24 +++++++++++++++++------- 3 files changed, 44 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/agent.rs b/src/agent.rs index f0e1292..7d4c4ef 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -217,6 +217,16 @@ pub fn run_turn( Err(error) => return Err(error), }; + // Placeholders are dropped before the assistant message is written: + // recording a call we refuse to run would leave it unanswered. + let before = outcome.tool_calls.len(); + outcome + .tool_calls + .retain(|call| !tools::is_placeholder(&call.arguments)); + if outcome.tool_calls.len() < before { + eprintln!("agent686: ignored {} empty tool call(s) from the model", before - outcome.tool_calls.len()); + } + // A missing id would make the tool result unattachable. for (index, call) in outcome.tool_calls.iter_mut().enumerate() { if call.id.is_empty() { @@ -351,7 +361,10 @@ fn execute( )) } }; - ui::tool_line(step, &call.name, &args); + // The bash approval prompt prints the command; do not print it here too. + let repeat_detail = !(tools::approval(&call.name) == Approval::EveryCall + && approver.will_prompt_bash()); + ui::tool_line(step, &call.name, &args, repeat_detail); if let Err(error) = tools::validate(&call.name, &args) { return ToolOutcome::Failed(format!("{error}; the call was not run")); } diff --git a/src/tools/mod.rs b/src/tools/mod.rs index 060dd7b..ddb1004 100644 --- a/src/tools/mod.rs +++ b/src/tools/mod.rs @@ -24,6 +24,19 @@ pub fn approval(name: &str) -> Approval { } } +/// A call with no arguments at all. Every tool here requires at least one, so +/// this is a placeholder some backends emit next to a real call, not an attempt. +pub fn is_placeholder(arguments: &str) -> bool { + let trimmed = arguments.trim(); + if trimmed.is_empty() { + return true; + } + matches!( + serde_json::from_str::(trimmed), + Ok(Value::Object(map)) if map.is_empty() + ) +} + /// Rejects a call that cannot possibly run, before a human is asked to approve /// it. An empty `cmd` used to mean an approval prompt for `run: `. pub fn validate(name: &str, args: &Value) -> Result<(), String> { diff --git a/src/ui.rs b/src/ui.rs index 2fdda1a..03e8dbe 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -109,7 +109,7 @@ impl Sink for Renderer { } } -pub fn tool_line(step: usize, name: &str, args: &serde_json::Value) { +pub fn tool_line(step: usize, name: &str, args: &serde_json::Value, include_detail: bool) { let detail = match name { "bash" => args .get("cmd") @@ -132,11 +132,12 @@ pub fn tool_line(step: usize, name: &str, args: &serde_json::Value) { .unwrap_or("") .to_string(), }; - println!( - "{} {}", - paint("1;36", &format!("● [{step}] {name}")), - detail - ); + let head = paint("1;36", &format!("● [{step}] {name}")); + if include_detail && !detail.is_empty() { + println!("{head} {detail}"); + } else { + println!("{head}"); + } let _ = std::io::stdout().flush(); } @@ -264,7 +265,9 @@ impl Approver { return true; } println!("{preview}"); - match self.ask(&format!("apply this change to {path}?"), true) { + // The path is already on the tool line above. + let _ = path; + match self.ask("apply this change?", true) { Answer::Yes => true, Answer::Always => { self.edits_allowed = true; @@ -274,6 +277,13 @@ impl Approver { } } + /// True when the next bash call will actually be shown to a human, which is + /// the only case where the command appears in the prompt rather than the + /// tool line. + pub fn will_prompt_bash(&self) -> bool { + !self.yolo && self.interactive + } + /// Every call, no memory: the point is seeing the command. pub fn allow_bash(&mut self, cmd: &str) -> bool { if self.yolo { -- cgit v1.2.3