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): thread run context through classified failure fetch tests
Steven Enamakel286084dde5d3
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_classified_failure_fetch_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_classified_failure_fetch_tests.rsindex cf0d8a96b4..9335349bdb 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware_classified_failure_fetch_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_classified_failure_fetch_tests.rs@@ -13,15 +13,16 @@ const FETCH_503: &str = "HTTP 503 Service Unavailable from example.test; the ser/// Run one failing `tool` call with `url` and `error` through the breaker.async fn fail_call(mw: &RepeatedToolFailureMiddleware,+ context: &mut RunContext<OpenHumanRunContext>,id: &str,tool: &str,arguments: serde_json::Value,error: &str,) {let mut call = TaToolCall::new(id, tool, arguments);- mw.before_tool(&mut ctx(), &(), &mut call).await.unwrap();+ mw.before_tool(context, &(), &mut call).await.unwrap();let mut result = failing_result(tool, error);- mw.after_tool(&mut ctx(), &(), &invocation(id, tool), &mut result)+ mw.after_tool(context, &(), &invocation(id, tool), &mut result).await.unwrap();}@@ -35,8 +36,10 @@ async fn one_blocked_website_does_not_stop_the_run() {let handle = SteeringHandle::allow_all();let slot = std::sync::Arc::new(std::sync::Mutex::new(None));let mw = RepeatedToolFailureMiddleware::new(handle.clone(), 3, slot.clone());+ let mut context = ctx();fail_call(&mw,+ &mut context,"blocked-1","web_fetch",fetch_args("https://example.test/a"),@@ -52,10 +55,12 @@ async fn repeated_refusals_from_one_host_stop_the_run_after_the_budget() {let handle = SteeringHandle::allow_all();let slot = std::sync::Arc::new(std::sync::Mutex::new(None));let mw = RepeatedToolFailureMiddleware::new(handle.clone(), 3, slot.clone());+ let mut context = ctx();// Different pages of one host: a new path must not reset the count.for (id, path) in [("r1", "a"), ("r2", "b")] {fail_call(&mw,+ &mut context,id,"web_fetch",fetch_args(&format!("https://example.test/{path}")),@@ -66,6 +71,7 @@ async fn repeated_refusals_from_one_host_stop_the_run_after_the_budget() {assert_eq!(drain_pause_count(&handle), 0);fail_call(&mw,+ &mut context,"r3","web_fetch",fetch_args("https://example.test/c?q=3"),@@ -84,6 +90,7 @@ async fn refusals_from_different_hosts_are_counted_separately() {let handle = SteeringHandle::allow_all();let slot = std::sync::Arc::new(std::sync::Mutex::new(None));let mw = RepeatedToolFailureMiddleware::new(handle.clone(), 3, slot.clone());+ let mut context = ctx();for (id, host) in [("h1", "a.test"),("h2", "b.test"),@@ -92,6 +99,7 @@ async fn refusals_from_different_hosts_are_counted_separately() {] {fail_call(&mw,+ &mut context,id,"web_fetch",fetch_args(&format!("https://{host}/page")),@@ -107,9 +115,11 @@ async fn a_good_fetch_from_a_host_clears_its_refusal_count() {let handle = SteeringHandle::allow_all();let slot = std::sync::Arc::new(std::sync::Mutex::new(None));let mw = RepeatedToolFailureMiddleware::new(handle.clone(), 3, slot.clone());+ let mut context = ctx();for id in ["c1", "c2"] {fail_call(&mw,+ &mut context,id,"web_fetch",fetch_args("https://example.test/a"),@@ -118,17 +128,18 @@ async fn a_good_fetch_from_a_host_clears_its_refusal_count() {.await;}let mut call = TaToolCall::new("c-ok", "web_fetch", fetch_args("https://example.test/open"));- mw.before_tool(&mut ctx(), &(), &mut call).await.unwrap();+ mw.before_tool(&mut context, &(), &mut call).await.unwrap();let mut ok = tool_result("web_fetch","status=200 url=https://example.test/open\nhello",);- mw.after_tool(&mut ctx(), &(), &invocation("c-ok", "web_fetch"), &mut ok)+ mw.after_tool(&mut context, &(), &invocation("c-ok", "web_fetch"), &mut ok).await.unwrap();for id in ["c3", "c4"] {fail_call(&mw,+ &mut context,id,"web_fetch",fetch_args("https://example.test/b"),@@ -149,8 +160,10 @@ async fn a_credentialed_endpoint_is_steered_off_then_stopped() {let handle = SteeringHandle::allow_all();let slot = std::sync::Arc::new(std::sync::Mutex::new(None));let mw = RepeatedToolFailureMiddleware::new(handle.clone(), 3, slot.clone());+ let mut context = ctx();fail_call(&mw,+ &mut context,"cred-1","composio_execute",serde_json::json!({"endpoint": "github/repos", "account_id": "acct-1"}),@@ -163,7 +176,7 @@ async fn a_credentialed_endpoint_is_steered_off_then_stopped() {"first refusal steers, not stops");assert!(slot.lock().unwrap().is_none());- let nudges = mw.take_pending_nudges();+ let nudges = drain_nudge_messages(&mw, &mut context).await;assert_eq!(nudges.len(), 1, "{nudges:?}");assert!(nudges[0].contains("`composio_execute` tool cannot be used"),@@ -171,6 +184,7 @@ async fn a_credentialed_endpoint_is_steered_off_then_stopped() {);fail_call(&mw,+ &mut context,"cred-2","composio_execute",serde_json::json!({"endpoint": "github/repos", "account_id": "acct-1"}),