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 | |
| 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-- | CHANGELOG.md | 9 | ||||
| -rw-r--r-- | Cargo.lock | 2 | ||||
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -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 | ||||
| -rw-r--r-- | tests/loop.rs | 60 | ||||
| -rw-r--r-- | tests/tools.rs | 13 |
9 files changed, 116 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d3e68e7..dc5c016 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md | |||
| @@ -7,6 +7,15 @@ break the interface, **PATCH** for bug fixes. | |||
| 7 | file, and the tool schemas the model sees. Anything a script or a resumed session | 7 | file, and the tool schemas the model sees. Anything a script or a resumed session |
| 8 | could depend on counts as API. | 8 | could depend on counts as API. |
| 9 | 9 | ||
| 10 | ## 0.12.1 | ||
| 11 | |||
| 12 | ### Fixed | ||
| 13 | - `bash` accepts `command` as an alias for `cmd`. A field report showed ~40% of | ||
| 14 | its calls were rejected because the model kept writing `command` instead of | ||
| 15 | `cmd`; the error was precise but named the *absence* of `cmd` rather than the | ||
| 16 | offending key, so the slip persisted for ~50 turns. The alias removes the whole | ||
| 17 | failure class. The schema still names the parameter `cmd`. | ||
| 18 | |||
| 10 | ## 0.12.0 | 19 | ## 0.12.0 |
| 11 | 20 | ||
| 12 | ### Changed (breaking) | 21 | ### Changed (breaking) |
| @@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" | |||
| 10 | 10 | ||
| 11 | [[package]] | 11 | [[package]] |
| 12 | name = "agent686" | 12 | name = "agent686" |
| 13 | version = "0.11.0" | 13 | version = "0.12.0" |
| 14 | dependencies = [ | 14 | dependencies = [ |
| 15 | "crossterm", | 15 | "crossterm", |
| 16 | "libc", | 16 | "libc", |
| @@ -1,6 +1,6 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "agent686" | 2 | name = "agent686" |
| 3 | version = "0.12.0" | 3 | version = "0.12.1" |
| 4 | edition = "2021" | 4 | edition = "2021" |
| 5 | description = "A small coding agent for Debian-class Linux" | 5 | description = "A small coding agent for Debian-class Linux" |
| 6 | publish = false | 6 | publish = false |
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(), |
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() { | |||
| 483 | "delta": { "tool_calls": [{ | 483 | "delta": { "tool_calls": [{ |
| 484 | "index": 0, | 484 | "index": 0, |
| 485 | "id": "call_wrong", | 485 | "id": "call_wrong", |
| 486 | "function": { "name": "bash", "arguments": "{\"command\":\"ls\"}" } | 486 | "function": { "name": "bash", "arguments": "{\"shell\":\"ls\"}" } |
| 487 | }]}, | 487 | }]}, |
| 488 | "finish_reason": "tool_calls" | 488 | "finish_reason": "tool_calls" |
| 489 | }] | 489 | }] |
| @@ -525,7 +525,63 @@ fn a_wrong_argument_key_names_both_keys() { | |||
| 525 | .expect("the turn should survive a wrong key"); | 525 | .expect("the turn should survive a wrong key"); |
| 526 | 526 | ||
| 527 | let result = history[3]["content"].as_str().unwrap(); | 527 | let result = history[3]["content"].as_str().unwrap(); |
| 528 | assert!(result.contains("`command`"), "should name what arrived: {result}"); | 528 | assert!(result.contains("`shell`"), "should name what arrived: {result}"); |
| 529 | assert!(result.contains("`cmd`"), "should name what was expected: {result}"); | 529 | assert!(result.contains("`cmd`"), "should name what was expected: {result}"); |
| 530 | assert!(!result.contains("denied"), "{result}"); | 530 | assert!(!result.contains("denied"), "{result}"); |
| 531 | } | 531 | } |
| 532 | |||
| 533 | #[test] | ||
| 534 | fn a_command_key_alias_runs_the_call() { | ||
| 535 | let dir = temp_dir("alias"); | ||
| 536 | let call = sse(&format!( | ||
| 537 | "data: {}\n\ndata: [DONE]\n\n", | ||
| 538 | json!({ | ||
| 539 | "choices": [{ | ||
| 540 | "delta": { "tool_calls": [{ | ||
| 541 | "index": 0, | ||
| 542 | "id": "call_alias", | ||
| 543 | "function": { "name": "bash", "arguments": "{\"command\":\"echo alias-ok\"}" } | ||
| 544 | }]}, | ||
| 545 | "finish_reason": "tool_calls" | ||
| 546 | }] | ||
| 547 | }) | ||
| 548 | )); | ||
| 549 | let final_round = sse( | ||
| 550 | "data: {\"choices\":[{\"delta\":{\"content\":\"done\"},\"finish_reason\":\"stop\"}]}\n\n\ | ||
| 551 | data: [DONE]\n\n", | ||
| 552 | ); | ||
| 553 | |||
| 554 | let base = serve_sequence(vec![call, final_round]); | ||
| 555 | std::env::set_var("AGENT686_DATA", dir.join("data")); | ||
| 556 | |||
| 557 | let system = agent::system_prompt(); | ||
| 558 | let mut session = Session::create("test-model", &system).unwrap(); | ||
| 559 | let cfg = Config { | ||
| 560 | base_url: base, | ||
| 561 | api_key: "test-key".into(), | ||
| 562 | model: "test-model".into(), | ||
| 563 | session: session.id.clone(), | ||
| 564 | yolo: true, | ||
| 565 | lenient: false, | ||
| 566 | system_ca: false, | ||
| 567 | provider: agent686::config::Provider::OpenCode, | ||
| 568 | allow_home: false, | ||
| 569 | allow_nogit: false, | ||
| 570 | }; | ||
| 571 | let mut history = agent::new_history(system); | ||
| 572 | let mut approver = Approver::new(true); | ||
| 573 | |||
| 574 | agent::run_turn( | ||
| 575 | &cfg, | ||
| 576 | &mut session, | ||
| 577 | &mut history, | ||
| 578 | "run it", | ||
| 579 | &AtomicBool::new(false), | ||
| 580 | &mut approver, | ||
| 581 | ) | ||
| 582 | .expect("the turn should succeed"); | ||
| 583 | |||
| 584 | let result = history[3]["content"].as_str().unwrap(); | ||
| 585 | assert!(result.contains("alias-ok"), "{result}"); | ||
| 586 | assert!(result.contains("[exit 0]"), "{result}"); | ||
| 587 | } | ||
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() { | |||
| 517 | "should report the file limit: {text}" | 517 | "should report the file limit: {text}" |
| 518 | ); | 518 | ); |
| 519 | } | 519 | } |
| 520 | |||
| 521 | #[test] | ||
| 522 | fn bash_accepts_command_as_an_alias_for_cmd() { | ||
| 523 | use agent686::tools::validate; | ||
| 524 | |||
| 525 | assert!(validate("bash", &json!({ "command": "ls" })).is_ok()); | ||
| 526 | assert!(validate("bash", &json!({ "command": " " })).is_err()); | ||
| 527 | assert!(validate("bash", &json!({})).is_err()); | ||
| 528 | |||
| 529 | let text = run("bash", &json!({ "command": "echo alias-works" })).unwrap(); | ||
| 530 | assert!(text.contains("alias-works"), "{text}"); | ||
| 531 | assert!(text.contains("[exit 0]"), "{text}"); | ||
| 532 | } | ||
