aboutsummaryrefslogtreecommitdiffstats
path: root/tests/loop.rs
diff options
context:
space:
mode:
authorsalmonik <salmon@2137697.xyz>2026-11-22 18:58:26 +0100
committersalmonik <salmon@2137697.xyz>2026-11-22 18:58:26 +0100
commit7c035acc6e282cdbaa3b0060a528660fa0dba0d4 (patch)
tree0998222677041f58b2759adc99d3515b8db2d404 /tests/loop.rs
parent0.12.0: provider is a type + URL, plus a config file (diff)
downloadagent686-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 'tests/loop.rs')
-rw-r--r--tests/loop.rs60
1 files changed, 58 insertions, 2 deletions
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]
534fn 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}