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. --- src/agent.rs | 22 +++++++++++++++++++++- src/tools/mod.rs | 10 +++++++--- src/tools/shell.rs | 6 +++++- src/ui.rs | 1 + 4 files changed, 34 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/agent.rs b/src/agent.rs index c3d77c1..f575908 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -372,6 +372,22 @@ fn execute( )); } }; + // A model keeps spelling the bash parameter `command` instead of `cmd`. The + // field report (0.12.0) shows that ~40% of calls died on this one-word slip, + // so accept the alias rather than teaching the model through repeated + // failures. Normalised once, here, so every downstream reader sees `cmd`. + let args = if call.name == "bash" && args.get("cmd").is_none() { + match args.get("command").and_then(|value| value.as_str()) { + Some(command) => { + let mut object = args.as_object().cloned().unwrap_or_default(); + object.insert("cmd".into(), serde_json::Value::String(command.to_string())); + serde_json::Value::Object(object) + } + None => args, + } + } else { + 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()); @@ -402,7 +418,11 @@ fn execute( Err(error) => ToolOutcome::Failed(error), }, Approval::EveryCall => { - let cmd = args.get("cmd").and_then(|v| v.as_str()).unwrap_or(""); + let cmd = args + .get("cmd") + .or_else(|| args.get("command")) + .and_then(|v| v.as_str()) + .unwrap_or(""); if approver.allow_bash(cmd) { match tools::run(&call.name, &args, cancel) { Ok(output) => ToolOutcome::Ok(output), diff --git a/src/tools/mod.rs b/src/tools/mod.rs index 7c6a921..5d6189f 100644 --- a/src/tools/mod.rs +++ b/src/tools/mod.rs @@ -75,7 +75,11 @@ pub fn validate(name: &str, args: &Value) -> Result<(), String> { }; match name { - "bash" => required_text("cmd"), + "bash" => match args.get("cmd").or_else(|| args.get("command")) { + Some(value) if !value.as_str().unwrap_or("").trim().is_empty() => Ok(()), + Some(_) => Err("`cmd` is present but empty".into()), + None => Err(missing("cmd")), + }, "read" => required_text("path"), "write" => { required_text("path")?; @@ -177,11 +181,11 @@ pub fn schemas() -> Vec { "type": "function", "function": { "name": "bash", - "description": "Run a shell command. Each call is a fresh shell at the working directory, so `cd` does not persist; pass cwd instead. stdout and stderr are reported in separate labelled sections when both produce output. Times out after timeout_seconds (default 120, maximum 600). Large output is truncated head+tail with an explicit marker; raise max_bytes if the match you need is in the middle.", + "description": "Run a shell command. The command string is the `cmd` parameter (not `command`). Each call is a fresh shell at the working directory, so `cd` does not persist; pass cwd instead. stdout and stderr are reported in separate labelled sections when both produce output. Times out after timeout_seconds (default 120, maximum 600). Large output is truncated head+tail with an explicit marker; raise max_bytes if the match you need is in the middle.", "parameters": { "type": "object", "properties": { - "cmd": { "type": "string" }, + "cmd": { "type": "string", "description": "the shell command to run" }, "cwd": { "type": "string", "description": "working directory (default: project root)" }, "timeout_seconds": { "type": "integer", "description": "1-600, default 120" }, "max_bytes": { "type": "integer", "description": "per-stream output budget, 1024-16777216, default 81920" } diff --git a/src/tools/shell.rs b/src/tools/shell.rs index c38f032..c64bab3 100644 --- a/src/tools/shell.rs +++ b/src/tools/shell.rs @@ -37,7 +37,11 @@ pub fn bash( timeout: Duration, cancel: &AtomicBool, ) -> Result { - let cmd = match args.get("cmd").and_then(|v| v.as_str()) { + let cmd = match args + .get("cmd") + .or_else(|| args.get("command")) + .and_then(|v| v.as_str()) + { Some(cmd) => cmd.to_string(), None => return Err("missing required argument `cmd`".into()), }; diff --git a/src/ui.rs b/src/ui.rs index 1d59ac4..e778eee 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -113,6 +113,7 @@ pub fn tool_line(label: &str, name: &str, args: &serde_json::Value, include_deta let detail = match name { "bash" => args .get("cmd") + .or_else(|| args.get("command")) .and_then(|v| v.as_str()) .unwrap_or("") .to_string(), -- cgit v1.2.3