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 --- tests/loop.rs | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'tests/loop.rs') diff --git a/tests/loop.rs b/tests/loop.rs index f90d19d..4fc1da5 100644 --- a/tests/loop.rs +++ b/tests/loop.rs @@ -345,7 +345,7 @@ fn an_empty_bash_call_is_never_approved() { "delta": { "tool_calls": [{ "index": 0, "id": "call_empty", - "function": { "name": "bash", "arguments": "{}" } + "function": { "name": "bash", "arguments": "{\"cmd\":\"\"}" } }]}, "finish_reason": "tool_calls" }] @@ -387,3 +387,54 @@ fn an_empty_bash_call_is_never_approved() { assert!(result.contains("`cmd` is required"), "{result}"); assert!(!result.contains("denied"), "must not reach an approval prompt: {result}"); } + +#[test] +fn a_tool_call_with_no_arguments_is_dropped_silently() { + let dir = temp_dir("placeholder"); + let placeholder = sse(&format!( + "data: {}\n\ndata: [DONE]\n\n", + json!({ + "choices": [{ + "delta": { "tool_calls": [{ + "index": 0, + "id": "call_ph", + "function": { "name": "bash", "arguments": "{}" } + }]}, + "finish_reason": "tool_calls" + }] + }) + )); + + let base = serve_sequence(vec![placeholder]); + std::env::set_var("AGENT686_DATA", dir.join("data")); + + let system = agent::system_prompt(); + let mut session = Session::create("test-model", &system).unwrap(); + let cfg = Config { + base_url: base, + api_key: "test-key".into(), + model: "test-model".into(), + session: session.id.clone(), + yolo: false, + }; + let mut history = agent::new_history(system); + let mut approver = Approver::new(false); + + agent::run_turn( + &cfg, + &mut session, + &mut history, + "run something", + &AtomicBool::new(false), + &mut approver, + ) + .expect("a placeholder must not fail the turn"); + + // system, user, assistant with the call removed: no tool message, no prompt. + assert_eq!(history.len(), 3, "{history:#?}"); + let assistant = history.last().unwrap(); + assert!( + assistant.get("tool_calls").is_none(), + "the placeholder must not be recorded: {assistant}" + ); +} -- cgit v1.2.3