diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-15 18:00:12 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-15 18:00:12 +0100 |
| commit | 8ae5bd48cf233315b5f36a7a6b39002a5e77f74b (patch) | |
| tree | 71c9b71f90f3cc64544dd506041468ee9bcbcda1 /tests/loop.rs | |
| parent | 0.6.2: resizing no longer duplicates the prompt (diff) | |
| download | agent686-8ae5bd48cf233315b5f36a7a6b39002a5e77f74b.tar.gz agent686-8ae5bd48cf233315b5f36a7a6b39002a5e77f74b.zip | |
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
Diffstat (limited to '')
| -rw-r--r-- | tests/loop.rs | 53 |
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] | ||
| 339 | fn 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 | } | ||
