summaryrefslogtreecommitdiffstats
path: root/tests/loop.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/loop.rs')
-rw-r--r--tests/loop.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/loop.rs b/tests/loop.rs
index b7e56f9..f90d19d 100644
--- a/tests/loop.rs
+++ b/tests/loop.rs
@@ -334,3 +334,56 @@ fn opening_a_session_with_unanswered_calls_repairs_it() {
334 }); 334 });
335 assert!(repaired, "missing result for call_2 should be synthesised"); 335 assert!(repaired, "missing result for call_2 should be synthesised");
336} 336}
337
338#[test]
339fn an_empty_bash_call_is_never_approved() {
340 let dir = temp_dir("empty-bash");
341 let empty_call = sse(&format!(
342 "data: {}\n\ndata: [DONE]\n\n",
343 json!({
344 "choices": [{
345 "delta": { "tool_calls": [{
346 "index": 0,
347 "id": "call_empty",
348 "function": { "name": "bash", "arguments": "{}" }
349 }]},
350 "finish_reason": "tool_calls"
351 }]
352 })
353 ));
354 let final_round = sse(
355 "data: {\"choices\":[{\"delta\":{\"content\":\"ok\"},\"finish_reason\":\"stop\"}]}\n\n\
356 data: [DONE]\n\n",
357 );
358
359 let base = serve_sequence(vec![empty_call, final_round]);
360 std::env::set_var("AGENT686_DATA", dir.join("data"));
361
362 let system = agent::system_prompt();
363 let mut session = Session::create("test-model", &system).unwrap();
364 let cfg = Config {
365 base_url: base,
366 api_key: "test-key".into(),
367 model: "test-model".into(),
368 session: session.id.clone(),
369 yolo: false,
370 };
371 let mut history = agent::new_history(system);
372 // Not a terminal: if this reaches the approval path it is denied, which the
373 // assertion below would catch.
374 let mut approver = Approver::new(false);
375
376 agent::run_turn(
377 &cfg,
378 &mut session,
379 &mut history,
380 "run something",
381 &AtomicBool::new(false),
382 &mut approver,
383 )
384 .expect("the turn should survive a malformed call");
385
386 let result = history[3]["content"].as_str().unwrap();
387 assert!(result.contains("`cmd` is required"), "{result}");
388 assert!(!result.contains("denied"), "must not reach an approval prompt: {result}");
389}