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/agent.rs | |
| 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 |
1 files changed, 21 insertions, 1 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), |
