diff options
| author | salmonik <salmon@2137697.xyz> | 2026-11-22 18:58:26 +0100 |
|---|---|---|
| committer | salmonik <salmon@2137697.xyz> | 2026-11-22 18:58:26 +0100 |
| commit | 7c035acc6e282cdbaa3b0060a528660fa0dba0d4 (patch) | |
| tree | 0998222677041f58b2759adc99d3515b8db2d404 /src | |
| parent | 0.12.0: provider is a type + URL, plus a config file (diff) | |
| download | agent686-7c035acc6e282cdbaa3b0060a528660fa0dba0d4.tar.gz agent686-7c035acc6e282cdbaa3b0060a528660fa0dba0d4.zip | |
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.
Diffstat (limited to '')
| -rw-r--r-- | src/agent.rs | 22 | ||||
| -rw-r--r-- | src/tools/mod.rs | 10 | ||||
| -rw-r--r-- | src/tools/shell.rs | 6 | ||||
| -rw-r--r-- | src/ui.rs | 1 |
4 files changed, 34 insertions, 5 deletions
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( | |||
| 372 | )); | 372 | )); |
| 373 | } | 373 | } |
| 374 | }; | 374 | }; |
| 375 | // A model keeps spelling the bash parameter `command` instead of `cmd`. The | ||
| 376 | // field report (0.12.0) shows that ~40% of calls died on this one-word slip, | ||
| 377 | // so accept the alias rather than teaching the model through repeated | ||
| 378 | // failures. Normalised once, here, so every downstream reader sees `cmd`. | ||
| 379 | let args = if call.name == "bash" && args.get("cmd").is_none() { | ||
| 380 | match args.get("command").and_then(|value| value.as_str()) { | ||
| 381 | Some(command) => { | ||
| 382 | let mut object = args.as_object().cloned().unwrap_or_default(); | ||
| 383 | object.insert("cmd".into(), serde_json::Value::String(command.to_string())); | ||
| 384 | serde_json::Value::Object(object) | ||
| 385 | } | ||
| 386 | None => args, | ||
| 387 | } | ||
| 388 | } else { | ||
| 389 | args | ||
| 390 | }; | ||
| 375 | // The bash approval prompt prints the command; do not print it here too. | 391 | // The bash approval prompt prints the command; do not print it here too. |
| 376 | let repeat_detail = !(tools::approval(&call.name) == Approval::EveryCall | 392 | let repeat_detail = !(tools::approval(&call.name) == Approval::EveryCall |
| 377 | && approver.will_prompt_bash()); | 393 | && approver.will_prompt_bash()); |
| @@ -402,7 +418,11 @@ fn execute( | |||
| 402 | Err(error) => ToolOutcome::Failed(error), | 418 | Err(error) => ToolOutcome::Failed(error), |
| 403 | }, | 419 | }, |
| 404 | Approval::EveryCall => { | 420 | Approval::EveryCall => { |
| 405 | let cmd = args.get("cmd").and_then(|v| v.as_str()).unwrap_or(""); | 421 | let cmd = args |
| 422 | .get("cmd") | ||
| 423 | .or_else(|| args.get("command")) | ||
| 424 | .and_then(|v| v.as_str()) | ||
| 425 | .unwrap_or(""); | ||
| 406 | if approver.allow_bash(cmd) { | 426 | if approver.allow_bash(cmd) { |
| 407 | match tools::run(&call.name, &args, cancel) { | 427 | match tools::run(&call.name, &args, cancel) { |
| 408 | Ok(output) => ToolOutcome::Ok(output), | 428 | 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> { | |||
| 75 | }; | 75 | }; |
| 76 | 76 | ||
| 77 | match name { | 77 | match name { |
| 78 | "bash" => required_text("cmd"), | 78 | "bash" => match args.get("cmd").or_else(|| args.get("command")) { |
| 79 | Some(value) if !value.as_str().unwrap_or("").trim().is_empty() => Ok(()), | ||
| 80 | Some(_) => Err("`cmd` is present but empty".into()), | ||
| 81 | None => Err(missing("cmd")), | ||
| 82 | }, | ||
| 79 | "read" => required_text("path"), | 83 | "read" => required_text("path"), |
| 80 | "write" => { | 84 | "write" => { |
| 81 | required_text("path")?; | 85 | required_text("path")?; |
| @@ -177,11 +181,11 @@ pub fn schemas() -> Vec<Value> { | |||
| 177 | "type": "function", | 181 | "type": "function", |
| 178 | "function": { | 182 | "function": { |
| 179 | "name": "bash", | 183 | "name": "bash", |
| 180 | "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.", | 184 | "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.", |
| 181 | "parameters": { | 185 | "parameters": { |
| 182 | "type": "object", | 186 | "type": "object", |
| 183 | "properties": { | 187 | "properties": { |
| 184 | "cmd": { "type": "string" }, | 188 | "cmd": { "type": "string", "description": "the shell command to run" }, |
| 185 | "cwd": { "type": "string", "description": "working directory (default: project root)" }, | 189 | "cwd": { "type": "string", "description": "working directory (default: project root)" }, |
| 186 | "timeout_seconds": { "type": "integer", "description": "1-600, default 120" }, | 190 | "timeout_seconds": { "type": "integer", "description": "1-600, default 120" }, |
| 187 | "max_bytes": { "type": "integer", "description": "per-stream output budget, 1024-16777216, default 81920" } | 191 | "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( | |||
| 37 | timeout: Duration, | 37 | timeout: Duration, |
| 38 | cancel: &AtomicBool, | 38 | cancel: &AtomicBool, |
| 39 | ) -> Result<String, String> { | 39 | ) -> Result<String, String> { |
| 40 | let cmd = match args.get("cmd").and_then(|v| v.as_str()) { | 40 | let cmd = match args |
| 41 | .get("cmd") | ||
| 42 | .or_else(|| args.get("command")) | ||
| 43 | .and_then(|v| v.as_str()) | ||
| 44 | { | ||
| 41 | Some(cmd) => cmd.to_string(), | 45 | Some(cmd) => cmd.to_string(), |
| 42 | None => return Err("missing required argument `cmd`".into()), | 46 | None => return Err("missing required argument `cmd`".into()), |
| 43 | }; | 47 | }; |
| @@ -113,6 +113,7 @@ pub fn tool_line(label: &str, name: &str, args: &serde_json::Value, include_deta | |||
| 113 | let detail = match name { | 113 | let detail = match name { |
| 114 | "bash" => args | 114 | "bash" => args |
| 115 | .get("cmd") | 115 | .get("cmd") |
| 116 | .or_else(|| args.get("command")) | ||
| 116 | .and_then(|v| v.as_str()) | 117 | .and_then(|v| v.as_str()) |
| 117 | .unwrap_or("") | 118 | .unwrap_or("") |
| 118 | .to_string(), | 119 | .to_string(), |
