Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test: add coverage for failure policy, escalation, and tool gating

Steven Enamakela4a9465a2a50
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_failure_policy_class_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_failure_policy_class_tests.rs
index 1f5e4dacf9..4740c2ac6f 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_failure_policy_class_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_failure_policy_class_tests.rs
@@ -203,6 +203,7 @@ fn production_read_tools() -> Vec<Box<dyn tinytools::Tool>> {
let security = std::sync::Arc::new(SecurityPolicy::default());
let tools: Vec<Box<dyn tinytools::Tool>> = vec![
Box::new(crate::tools::implementations::network::web_fetch_tool(
+ &crate::core::runtime::DispatchCtx::ambient(),
security.clone(),
vec!["example.com".into()],
None,
diff --git a/crates/openhuman-core/src/agent/triage/escalation_tests.rs b/crates/openhuman-core/src/agent/triage/escalation_tests.rs
index 9598cf97d3..f4ca9e6adc 100644
--- a/crates/openhuman-core/src/agent/triage/escalation_tests.rs
+++ b/crates/openhuman-core/src/agent/triage/escalation_tests.rs
@@ -124,7 +124,7 @@ async fn apply_decision_drop_only_publishes_evaluated() {
})
}));
- apply_decision(run(TriageAction::Drop), &envelope)
+ apply_decision(&crate::core::runtime::DispatchCtx::ambient(), run(TriageAction::Drop), &envelope)
.await
.expect("drop should not fail");
@@ -163,7 +163,7 @@ async fn apply_decision_acknowledge_only_publishes_evaluated() {
})
}));
- apply_decision(run(TriageAction::Acknowledge), &envelope)
+ apply_decision(&crate::core::runtime::DispatchCtx::ambient(), run(TriageAction::Acknowledge), &envelope)
.await
.expect("acknowledge should not fail");
@@ -211,6 +211,7 @@ async fn apply_decision_react_failure_publishes_failed_event() {
}));
let result = apply_decision(
+ &crate::core::runtime::DispatchCtx::ambient(),
run_with_target(TriageAction::React, &missing_target, "handle this"),
&envelope,
)
@@ -265,6 +266,7 @@ async fn apply_decision_escalate_failure_publishes_failed_event() {
));
let result = apply_decision(
+ &crate::core::runtime::DispatchCtx::ambient(),
run_with_target(TriageAction::Escalate, &missing_target, "escalate this"),
&envelope,
)
diff --git a/crates/openhuman-core/src/tools/impl/network/gate_tests.rs b/crates/openhuman-core/src/tools/impl/network/gate_tests.rs
index a3451b2074..96c9991686 100644
--- a/crates/openhuman-core/src/tools/impl/network/gate_tests.rs
+++ b/crates/openhuman-core/src/tools/impl/network/gate_tests.rs
@@ -14,7 +14,7 @@ fn policy(autonomy: AutonomyLevel, max_actions_per_hour: u32) -> Arc<SecurityPol
}
fn http(security: Arc<SecurityPolicy>) -> HttpRequestTool {
- super::super::host::http_request_tool(security, vec!["example.com".into()], 1_000_000, 30)
+ super::super::host::http_request_tool(&crate::core::runtime::DispatchCtx::ambient(), security, vec!["example.com".into()], 1_000_000, 30)
}
// --- the gate answers with the policy's own decisions -----------------------
@@ -120,6 +120,7 @@ async fn web_fetch_and_curl_are_blocked_under_local_only_privacy_mode() {
let _mode = super::super::local_only_scope();
let security = Arc::new(SecurityPolicy::default());
let fetch = super::super::host::web_fetch_tool(
+ &crate::core::runtime::DispatchCtx::ambient(),
security.clone(),
vec!["example.com".into()],
None,
@@ -196,6 +197,7 @@ fn readonly_http_request_is_not_external_effect_because_execute_blocks() {
#[test]
fn web_fetch_is_read_only_and_never_prompts() {
let tool: WebFetchTool = super::super::host::web_fetch_tool(
+ &crate::core::runtime::DispatchCtx::ambient(),
policy(AutonomyLevel::Supervised, 100),
vec![],
None,
diff --git a/crates/openhuman-core/src/tools/ops_tests_domain_family_tests.rs b/crates/openhuman-core/src/tools/ops_tests_domain_family_tests.rs
index 49d2a7add9..64124b3ff0 100644
--- a/crates/openhuman-core/src/tools/ops_tests_domain_family_tests.rs
+++ b/crates/openhuman-core/src/tools/ops_tests_domain_family_tests.rs
@@ -119,7 +119,7 @@ async fn readonly_acting_tools_carry_policy_blocked_marker() {
serde_json::json!({ "url": "https://example.com" }),
),
(
- Box::new(http_request_tool(sec.clone(), vec![], 0, 0)),
+ Box::new(http_request_tool(&crate::core::runtime::DispatchCtx::ambient(), sec.clone(), vec![], 0, 0)),
serde_json::json!({ "url": "https://example.com" }),
),
];
diff --git a/crates/openhuman-core/src/tools/per_call_tests.rs b/crates/openhuman-core/src/tools/per_call_tests.rs
index 4c51a3fc9c..6c55ed5542 100644
--- a/crates/openhuman-core/src/tools/per_call_tests.rs
+++ b/crates/openhuman-core/src/tools/per_call_tests.rs
@@ -48,7 +48,7 @@ fn chat(thread: &str) -> ApprovalChatContext {
}
fn tool() -> PerCallTool<Probe> {
- PerCallTool::new(|chat| Probe {
+ PerCallTool::new(|chat, _ctx| Probe {
built_for: chat.cloned(),
})
}