The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(middleware): reorder test module declarations and fix formatting
Steven Enamakel96f92bea183a
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_file_read.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_file_read.rsindex df171745cc..96ae661fef 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_file_read.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_file_read.rs@@ -66,7 +66,9 @@ pub(crate) fn is_file_read_command(command: &str) -> bool {.filter(|s| !s.is_empty()){let mut words = segment.split_whitespace();- let Some(program) = words.next() else { continue };+ let Some(program) = words.next() else {+ continue;+ };let program = program.rsplit('/').next().unwrap_or(program);if program == "sed"&& segmentdiff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_file_read_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_file_read_tests.rsindex 2aaff7c951..e2deb697e0 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_file_read_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_file_read_tests.rs@@ -40,8 +40,14 @@ fn anything_that_runs_writes_or_searches_is_not() {fn file_read_tools_and_wrapped_calls_are_recognised() {assert!(is_file_read_call("file_read", &json!({"path": "a.rs"})));assert!(is_file_read_call("shell", &json!({"command": "cat a.rs"})));- assert!(!is_file_read_call("shell", &json!({"command": "cargo test"})));- assert!(!is_file_read_call("web_fetch", &json!({"url": "https://example.com"})));+ assert!(!is_file_read_call(+ "shell",+ &json!({"command": "cargo test"})+ ));+ assert!(!is_file_read_call(+ "web_fetch",+ &json!({"url": "https://example.com"})+ ));assert!(is_file_read_call("use_skill",&json!({"tool": "shell", "args": {"command": "cat a.rs"}})diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tests.rsindex a25c9eb276..2506b8eb30 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tests.rs@@ -407,9 +407,9 @@ mod research_budget_tests;mod memory_and_hooks_tests;#[path = "middleware_tool_output_artifact_tests.rs"]mod tool_output_artifact_tests;-#[path = "middleware_tool_output_tests.rs"]-mod tool_output_tests;#[path = "middleware_tool_output_file_read_tests.rs"]mod tool_output_file_read_tests;+#[path = "middleware_tool_output_tests.rs"]+mod tool_output_tests;#[path = "middleware_tool_policy_tests.rs"]mod tool_policy_tests;diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_file_read_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_file_read_tests.rsnew file mode 100644index 0000000000..112b37e3b3--- /dev/null+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_file_read_tests.rs@@ -0,0 +1,72 @@+//! `ToolOutputMiddleware` and file reads: a call that only prints files the+//! agent can re-read never gets an LLM payload summary. Within the result+//! budget it is left verbatim; past it TinyJuice compacts it deterministically.++use super::*;++/// Run one shell call with `command` through `before_tool` and `after_tool`.+async fn run_shell(+ mw: &ToolOutputMiddleware,+ id: &str,+ command: &str,+ output: &str,+) -> (+ String,+ Vec<crate::inference::tokenjuice::types::CompactRequest>,+) {+ let mut ctx = ctx();+ let mut call = TaToolCall::new(id, "shell", json!({ "command": command }));+ mw.before_tool(&mut ctx, &(), &mut call).await.unwrap();+ let mut result = tool_result("shell", output);+ let (outcome, requests) =+ with_module(mw.after_tool(&mut ctx, &(), &invocation(id, "shell"), &mut result)).await;+ outcome.expect("after_tool succeeds");+ (result_text(&result), requests)+}++#[tokio::test]+async fn a_file_read_within_the_budget_is_left_verbatim() {+ let stub = StubSummarizer::replying(Ok("a paraphrase of the file".into()));+ let mut mw = summarizer_mw(stub.clone());+ mw.tokenjuice_compaction_enabled = true;+ mw.budget_bytes = 16 * 1024;+ let file = "package vm\n\nfunc funcExpr() {}\n".repeat(400); // ~13 KB+ let (text, requests) =+ run_shell(&mw, "read-1", "cd /app && cat vm/vmExprFunction.go", &file).await;++ assert_eq!(text, file, "the agent asked for the file's exact text");+ assert!(!stub.was_prepared(), "no summary call for a file read");+ assert!(+ requests.is_empty(),+ "nothing to ask TinyJuice within the budget"+ );+}++#[tokio::test]+async fn a_file_read_past_the_budget_is_compacted_without_a_summary() {+ let stub = StubSummarizer::replying(Ok("a paraphrase of the file".into()));+ let mut mw = summarizer_mw(stub.clone());+ mw.tokenjuice_compaction_enabled = true;+ mw.budget_bytes = 4 * 1024;+ let file = "package vm\n\nfunc funcExpr() {}\n".repeat(400);+ let (_, requests) =+ run_shell(&mw, "read-2", "sed -n '1,400p' vm/vmExprFunction.go", &file).await;++ assert!(!stub.was_prepared(), "no summary call for a file read");+ assert_eq!(requests.len(), 1, "TinyJuice still compacts it");+ assert!(+ requests[0].context_token.is_none(),+ "and is given no summary call to make"+ );+}++#[tokio::test]+async fn other_shell_output_is_still_summarized() {+ let stub = StubSummarizer::replying(Ok("tests: 3 failed".into()));+ let mw = summarizer_mw(stub.clone());+ let log = "--- FAIL: TestDefaults (0.00s)\n".repeat(400);+ let (text, _) = run_shell(&mw, "test-1", "go test ./vm/...", &log).await;++ assert!(stub.was_prepared(), "a test log is not a file on disk");+ assert!(text.contains("tests: 3 failed"), "{text}");+}