From 6df7a6403d88a4492ab6ea1c519dcae3a202be96 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 18 Nov 2026 12:01:38 +0100 Subject: 0.9.0: distinguishable tool errors, separated stderr, configurable limits From a field report porting a Neovim config to Helix: - validate() now separates 'empty value', 'wrong key (here is what you sent)' and 'no arguments at all, retry' instead of one false message for all four causes - named calls with no arguments are answered rather than dropped silently - bash keeps stdout and stderr in labelled sections when both produce output - bash gains timeout_seconds (1-600) and max_bytes, and says when output was cut - tool lines/results carry [step.call] labels when a step has several calls - invalid JSON errors include a preview of what arrived --- tests/loop.rs | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 9 deletions(-) (limited to 'tests/loop.rs') diff --git a/tests/loop.rs b/tests/loop.rs index 4fc1da5..e913302 100644 --- a/tests/loop.rs +++ b/tests/loop.rs @@ -384,12 +384,12 @@ fn an_empty_bash_call_is_never_approved() { .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("`cmd` is present but empty"), "{result}"); assert!(!result.contains("denied"), "must not reach an approval prompt: {result}"); } #[test] -fn a_tool_call_with_no_arguments_is_dropped_silently() { +fn a_tool_call_with_no_arguments_is_reported_to_the_model() { let dir = temp_dir("placeholder"); let placeholder = sse(&format!( "data: {}\n\ndata: [DONE]\n\n", @@ -405,7 +405,12 @@ fn a_tool_call_with_no_arguments_is_dropped_silently() { }) )); - let base = serve_sequence(vec![placeholder]); + let final_round = sse( + "data: {\"choices\":[{\"delta\":{\"content\":\"ok\"},\"finish_reason\":\"stop\"}]}\n\n\ + data: [DONE]\n\n", + ); + + let base = serve_sequence(vec![placeholder, final_round]); std::env::set_var("AGENT686_DATA", dir.join("data")); let system = agent::system_prompt(); @@ -430,11 +435,62 @@ fn a_tool_call_with_no_arguments_is_dropped_silently() { ) .expect("a placeholder must not fail the turn"); - // system, user, assistant with the call removed: no tool message, no prompt. - assert_eq!(history.len(), 3, "{history:#?}"); - let assistant = history.last().unwrap(); - assert!( - assistant.get("tool_calls").is_none(), - "the placeholder must not be recorded: {assistant}" + // The named call is kept and answered, so the model can retry instead of + // silently losing it: system, user, assistant, tool, assistant. + assert_eq!(history.len(), 5, "{history:#?}"); + let result = history[3]["content"].as_str().unwrap(); + assert!(result.contains("no arguments at all"), "{result}"); + assert!(result.contains("retry"), "{result}"); +} + +#[test] +fn a_wrong_argument_key_names_both_keys() { + let dir = temp_dir("wrong-key"); + let call = sse(&format!( + "data: {}\n\ndata: [DONE]\n\n", + json!({ + "choices": [{ + "delta": { "tool_calls": [{ + "index": 0, + "id": "call_wrong", + "function": { "name": "bash", "arguments": "{\"command\":\"ls\"}" } + }]}, + "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![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); + let mut approver = Approver::new(false); + + agent::run_turn( + &cfg, + &mut session, + &mut history, + "run it", + &AtomicBool::new(false), + &mut approver, + ) + .expect("the turn should survive a wrong key"); + + let result = history[3]["content"].as_str().unwrap(); + assert!(result.contains("`command`"), "should name what arrived: {result}"); + assert!(result.contains("`cmd`"), "should name what was expected: {result}"); + assert!(!result.contains("denied"), "{result}"); } -- cgit v1.2.3