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
test(tinyagents): cover run context isolation in failure middleware
Steven Enamakel520eae3e61d5
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rsindex a0c3689ab1..7308c11c2c 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs@@ -31,6 +31,7 @@ pub(crate) struct ToolPolicyMiddleware {/// TinyAgents owns evaluation and denial short-circuiting.gate: ToolPolicyGateMiddleware<OpenHumanRunContext>,/// OpenHuman's concrete channel ceiling and disclosure snapshot.+ #[cfg(test)]host: Arc<ToolPolicyHostState>,}@@ -114,7 +115,11 @@ impl ToolPolicyMiddleware {.with_post_gate(Arc::new(move |_ctx, call| {post_host.render_skill_for_session(call)}));- Self { gate, host }+ Self {+ gate,+ #[cfg(test)]+ host,+ }}// Keep focused host-adapter tests on the concrete disclosure callbacksdiff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_loop_guard_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_loop_guard_tests.rsindex 1a40711389..3d39b2da40 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware_loop_guard_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_loop_guard_tests.rs@@ -552,3 +552,47 @@ async fn existing_error_is_some_behavior_is_unchanged_by_body_level_check() {"the third identical error+ok:false result halts, same as a plain error");}++#[tokio::test]+async fn shared_failure_middleware_keeps_distinct_run_contexts_isolated() {+ let handle = SteeringHandle::allow_all();+ let middleware = RepeatedToolFailureMiddleware::new(+ handle.clone(),+ 3,+ std::sync::Arc::new(std::sync::Mutex::new(None)),+ );+ let mut first_run = ctx();+ let mut second_run = ctx();++ for (context, id) in [(&mut first_run, "first"), (&mut second_run, "second")] {+ for attempt in 0..2 {+ let mut result = failing_result("flaky", "same failure");+ middleware+ .after_tool(+ context,+ &(),+ &invocation(format!("{id}-{attempt}"), "flaky"),+ &mut result,+ )+ .await+ .unwrap();+ }+ }+ assert_eq!(drain_pause_count(&handle), 0);++ let mut result = failing_result("flaky", "same failure");+ middleware+ .after_tool(+ &mut first_run,+ &(),+ &invocation("first-third", "flaky"),+ &mut result,+ )+ .await+ .unwrap();+ assert_eq!(+ drain_pause_count(&handle),+ 1,+ "only the first run's third failure reaches its own halt threshold"+ );+}