From 7c035acc6e282cdbaa3b0060a528660fa0dba0d4 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 22 Nov 2026 18:58:26 +0100 Subject: 0.12.1: accept `command` as an alias for `cmd` in bash A field report showed ~40% of bash calls died on a one-word slip (command vs cmd); the alias removes the failure class instead of improving the error for it. --- tests/loop.rs | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- tests/tools.rs | 13 +++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/loop.rs b/tests/loop.rs index 7e6086f..73592f0 100644 --- a/tests/loop.rs +++ b/tests/loop.rs @@ -483,7 +483,7 @@ fn a_wrong_argument_key_names_both_keys() { "delta": { "tool_calls": [{ "index": 0, "id": "call_wrong", - "function": { "name": "bash", "arguments": "{\"command\":\"ls\"}" } + "function": { "name": "bash", "arguments": "{\"shell\":\"ls\"}" } }]}, "finish_reason": "tool_calls" }] @@ -525,7 +525,63 @@ fn a_wrong_argument_key_names_both_keys() { .expect("the turn should survive a wrong key"); let result = history[3]["content"].as_str().unwrap(); - assert!(result.contains("`command`"), "should name what arrived: {result}"); + assert!(result.contains("`shell`"), "should name what arrived: {result}"); assert!(result.contains("`cmd`"), "should name what was expected: {result}"); assert!(!result.contains("denied"), "{result}"); } + +#[test] +fn a_command_key_alias_runs_the_call() { + let dir = temp_dir("alias"); + let call = sse(&format!( + "data: {}\n\ndata: [DONE]\n\n", + json!({ + "choices": [{ + "delta": { "tool_calls": [{ + "index": 0, + "id": "call_alias", + "function": { "name": "bash", "arguments": "{\"command\":\"echo alias-ok\"}" } + }]}, + "finish_reason": "tool_calls" + }] + }) + )); + let final_round = sse( + "data: {\"choices\":[{\"delta\":{\"content\":\"done\"},\"finish_reason\":\"stop\"}]}\n\n\ + data: [DONE]\n\n", + ); + + let base = serve_sequence(vec![call, final_round]); + 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: true, + lenient: false, + system_ca: false, + provider: agent686::config::Provider::OpenCode, + allow_home: false, + allow_nogit: false, + }; + let mut history = agent::new_history(system); + let mut approver = Approver::new(true); + + agent::run_turn( + &cfg, + &mut session, + &mut history, + "run it", + &AtomicBool::new(false), + &mut approver, + ) + .expect("the turn should succeed"); + + let result = history[3]["content"].as_str().unwrap(); + assert!(result.contains("alias-ok"), "{result}"); + assert!(result.contains("[exit 0]"), "{result}"); +} diff --git a/tests/tools.rs b/tests/tools.rs index 4a8176e..0321bf8 100644 --- a/tests/tools.rs +++ b/tests/tools.rs @@ -517,3 +517,16 @@ fn a_pipeline_that_exceeds_the_file_limit_is_reported() { "should report the file limit: {text}" ); } + +#[test] +fn bash_accepts_command_as_an_alias_for_cmd() { + use agent686::tools::validate; + + assert!(validate("bash", &json!({ "command": "ls" })).is_ok()); + assert!(validate("bash", &json!({ "command": " " })).is_err()); + assert!(validate("bash", &json!({})).is_err()); + + let text = run("bash", &json!({ "command": "echo alias-works" })).unwrap(); + assert!(text.contains("alias-works"), "{text}"); + assert!(text.contains("[exit 0]"), "{text}"); +} -- cgit v1.2.3