From 8ae5bd48cf233315b5f36a7a6b39002a5e77f74b Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 15 Nov 2026 18:00:12 +0100 Subject: 0.7.0: resume shows where you left off; no approval for unparsable calls - --continue prints the last answer, or the last reasoning block if there was none - tool arguments are validated before prompting, so an empty bash call becomes an error for the model instead of a blank approval - empty placeholder tool calls are dropped and reported - sessions tolerate invalid UTF-8 lines from a torn write - AGENT686_DEBUG_STREAM=1 dumps SSE frames --- tests/loop.rs | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'tests/loop.rs') 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() { }); assert!(repaired, "missing result for call_2 should be synthesised"); } + +#[test] +fn an_empty_bash_call_is_never_approved() { + let dir = temp_dir("empty-bash"); + let empty_call = sse(&format!( + "data: {}\n\ndata: [DONE]\n\n", + json!({ + "choices": [{ + "delta": { "tool_calls": [{ + "index": 0, + "id": "call_empty", + "function": { "name": "bash", "arguments": "{}" } + }]}, + "finish_reason": "tool_calls" + }] + }) + )); + let final_round = sse( + "data: {\"choices\":[{\"delta\":{\"content\":\"ok\"},\"finish_reason\":\"stop\"}]}\n\n\ + data: [DONE]\n\n", + ); + + let base = serve_sequence(vec![empty_call, final_round]); + std::env::set_var("AGENT686_DATA", dir.join("data")); + + let system = agent::system_prompt(); + let mut session = Session::create("test-model", &system).unwrap(); + let cfg = Config { + base_url: base, + api_key: "test-key".into(), + model: "test-model".into(), + session: session.id.clone(), + yolo: false, + }; + let mut history = agent::new_history(system); + // Not a terminal: if this reaches the approval path it is denied, which the + // assertion below would catch. + let mut approver = Approver::new(false); + + agent::run_turn( + &cfg, + &mut session, + &mut history, + "run something", + &AtomicBool::new(false), + &mut approver, + ) + .expect("the turn should survive a malformed call"); + + let result = history[3]["content"].as_str().unwrap(); + assert!(result.contains("`cmd` is required"), "{result}"); + assert!(!result.contains("denied"), "must not reach an approval prompt: {result}"); +} -- cgit v1.2.3