aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-15 18:31:16 +0100
committersalmonik <salmonik@tuta.io>2026-11-15 18:31:16 +0100
commit0ef2b709b5ec2d44fc947a8b96572f66ee8b3bc9 (patch)
treee0ee8b2824281eb9f672b9cb46f7d50ad3857b3d /src
parent0.7.0: resume shows where you left off; no approval for unparsable calls (diff)
downloadagent686-0ef2b709b5ec2d44fc947a8b96572f66ee8b3bc9.tar.gz
agent686-0ef2b709b5ec2d44fc947a8b96572f66ee8b3bc9.zip
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
Diffstat (limited to '')
-rw-r--r--src/agent.rs15
-rw-r--r--src/tools/mod.rs13
-rw-r--r--src/ui.rs24
3 files changed, 44 insertions, 8 deletions
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(
217 Err(error) => return Err(error), 217 Err(error) => return Err(error),
218 }; 218 };
219 219
220 // Placeholders are dropped before the assistant message is written:
221 // recording a call we refuse to run would leave it unanswered.
222 let before = outcome.tool_calls.len();
223 outcome
224 .tool_calls
225 .retain(|call| !tools::is_placeholder(&call.arguments));
226 if outcome.tool_calls.len() < before {
227 eprintln!("agent686: ignored {} empty tool call(s) from the model", before - outcome.tool_calls.len());
228 }
229
220 // A missing id would make the tool result unattachable. 230 // A missing id would make the tool result unattachable.
221 for (index, call) in outcome.tool_calls.iter_mut().enumerate() { 231 for (index, call) in outcome.tool_calls.iter_mut().enumerate() {
222 if call.id.is_empty() { 232 if call.id.is_empty() {
@@ -351,7 +361,10 @@ fn execute(
351 )) 361 ))
352 } 362 }
353 }; 363 };
354 ui::tool_line(step, &call.name, &args); 364 // The bash approval prompt prints the command; do not print it here too.
365 let repeat_detail = !(tools::approval(&call.name) == Approval::EveryCall
366 && approver.will_prompt_bash());
367 ui::tool_line(step, &call.name, &args, repeat_detail);
355 if let Err(error) = tools::validate(&call.name, &args) { 368 if let Err(error) = tools::validate(&call.name, &args) {
356 return ToolOutcome::Failed(format!("{error}; the call was not run")); 369 return ToolOutcome::Failed(format!("{error}; the call was not run"));
357 } 370 }
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 {
24 } 24 }
25} 25}
26 26
27/// A call with no arguments at all. Every tool here requires at least one, so
28/// this is a placeholder some backends emit next to a real call, not an attempt.
29pub fn is_placeholder(arguments: &str) -> bool {
30 let trimmed = arguments.trim();
31 if trimmed.is_empty() {
32 return true;
33 }
34 matches!(
35 serde_json::from_str::<Value>(trimmed),
36 Ok(Value::Object(map)) if map.is_empty()
37 )
38}
39
27/// Rejects a call that cannot possibly run, before a human is asked to approve 40/// Rejects a call that cannot possibly run, before a human is asked to approve
28/// it. An empty `cmd` used to mean an approval prompt for `run: `. 41/// it. An empty `cmd` used to mean an approval prompt for `run: `.
29pub fn validate(name: &str, args: &Value) -> Result<(), String> { 42pub 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<W: Write> Sink for Renderer<W> {
109 } 109 }
110} 110}
111 111
112pub fn tool_line(step: usize, name: &str, args: &serde_json::Value) { 112pub fn tool_line(step: usize, name: &str, args: &serde_json::Value, include_detail: bool) {
113 let detail = match name { 113 let detail = match name {
114 "bash" => args 114 "bash" => args
115 .get("cmd") 115 .get("cmd")
@@ -132,11 +132,12 @@ pub fn tool_line(step: usize, name: &str, args: &serde_json::Value) {
132 .unwrap_or("") 132 .unwrap_or("")
133 .to_string(), 133 .to_string(),
134 }; 134 };
135 println!( 135 let head = paint("1;36", &format!("● [{step}] {name}"));
136 "{} {}", 136 if include_detail && !detail.is_empty() {
137 paint("1;36", &format!("● [{step}] {name}")), 137 println!("{head} {detail}");
138 detail 138 } else {
139 ); 139 println!("{head}");
140 }
140 let _ = std::io::stdout().flush(); 141 let _ = std::io::stdout().flush();
141} 142}
142 143
@@ -264,7 +265,9 @@ impl Approver {
264 return true; 265 return true;
265 } 266 }
266 println!("{preview}"); 267 println!("{preview}");
267 match self.ask(&format!("apply this change to {path}?"), true) { 268 // The path is already on the tool line above.
269 let _ = path;
270 match self.ask("apply this change?", true) {
268 Answer::Yes => true, 271 Answer::Yes => true,
269 Answer::Always => { 272 Answer::Always => {
270 self.edits_allowed = true; 273 self.edits_allowed = true;
@@ -274,6 +277,13 @@ impl Approver {
274 } 277 }
275 } 278 }
276 279
280 /// True when the next bash call will actually be shown to a human, which is
281 /// the only case where the command appears in the prompt rather than the
282 /// tool line.
283 pub fn will_prompt_bash(&self) -> bool {
284 !self.yolo && self.interactive
285 }
286
277 /// Every call, no memory: the point is seeing the command. 287 /// Every call, no memory: the point is seeing the command.
278 pub fn allow_bash(&mut self, cmd: &str) -> bool { 288 pub fn allow_bash(&mut self, cmd: &str) -> bool {
279 if self.yolo { 289 if self.yolo {