summaryrefslogtreecommitdiffstats
path: root/tests/tools.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-18 12:28:29 +0100
committersalmonik <salmonik@tuta.io>2026-11-18 12:28:29 +0100
commit84e70c0e73460e5db1297c47d02d9b76802bfdf7 (patch)
treeff0cd75141a28d7112b4f82b2c74bdba91b332a3 /tests/tools.rs
parent0.9.0: distinguishable tool errors, separated stderr, configurable limits (diff)
downloadagent686-84e70c0e73460e5db1297c47d02d9b76802bfdf7.tar.gz
agent686-84e70c0e73460e5db1297c47d02d9b76802bfdf7.zip
0.9.1: correctness fixes from the audit
- 64 MiB limit detected by file length, so pipelines and redirects are reported - bash temp files removed on every path via a scope guard - validate requires content/new as the schemas declare (present, may be empty) - Session::open folds in model-switch records; resume matches --list - combining mark at a wrap boundary no longer counts as a new row - --flag=value accepted; flag-shaped values rejected - dead code removed; last_reply folded into open (one read per resume)
Diffstat (limited to 'tests/tools.rs')
-rw-r--r--tests/tools.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/tools.rs b/tests/tools.rs
index e54b5ff..4a8176e 100644
--- a/tests/tools.rs
+++ b/tests/tools.rs
@@ -490,3 +490,30 @@ fn bash_honours_a_per_call_output_budget() {
490 assert!(text.contains("output truncated"), "{text}"); 490 assert!(text.contains("output truncated"), "{text}");
491 assert!(text.len() < 10_000, "output was {} bytes", text.len()); 491 assert!(text.len() < 10_000, "output was {} bytes", text.len());
492} 492}
493
494#[test]
495fn validate_requires_content_and_new_but_allows_empty() {
496 use agent686::tools::validate;
497
498 // Missing, not empty.
499 assert!(validate("write", &json!({ "path": "a" })).is_err());
500 assert!(validate("edit", &json!({ "path": "a", "old": "b" })).is_err());
501 // Present but empty is legitimate (empty file, deletion).
502 assert!(validate("write", &json!({ "path": "a", "content": "" })).is_ok());
503 assert!(validate("edit", &json!({ "path": "a", "old": "b", "new": "" })).is_ok());
504}
505
506#[test]
507fn a_pipeline_that_exceeds_the_file_limit_is_reported() {
508 // 70 MiB through a pipeline: the grandchild (head) is the writer, so only the
509 // file-length check can detect the limit.
510 let text = run(
511 "bash",
512 &json!({ "cmd": "yes | head -c 70000000" }),
513 )
514 .unwrap();
515 assert!(
516 text.contains("output exceeded 64 MiB"),
517 "should report the file limit: {text}"
518 );
519}