Skip to content

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

test(agent): add coverage for attachments, markers, approval guard, and host checks

Steven Enamakelca0ad564497d
diff --git a/crates/openhuman-core/src/agent/attachments/mod_access_tests.rs b/crates/openhuman-core/src/agent/attachments/mod_access_tests.rs
index c58c39b78c..243048c1f8 100644
--- a/crates/openhuman-core/src/agent/attachments/mod_access_tests.rs
+++ b/crates/openhuman-core/src/agent/attachments/mod_access_tests.rs
@@ -77,6 +77,7 @@ async fn direct_upload_requires_runtime_authority_and_external_input_cannot_crea
async fn delegation_rejects_malformed_explicit_paths_and_external_reads_before_configuration() {
assert_eq!(
delegation_prompt(
+&crate::core::runtime::DispatchCtx::ambient(),
"mention picture.png in prose",
&serde_json::json!({}),
None,
@@ -94,6 +95,7 @@ async fn delegation_rejects_malformed_explicit_paths_and_external_reads_before_c
serde_json::json!(["picture\u{0}.png"]),
] {
assert!(delegation_prompt(
+&crate::core::runtime::DispatchCtx::ambient(),
"task",
&serde_json::json!({"image_paths": image_paths}),
None,
@@ -103,6 +105,7 @@ async fn delegation_rejects_malformed_explicit_paths_and_external_reads_before_c
.is_err());
}
let error = delegation_prompt(
+&crate::core::runtime::DispatchCtx::ambient(),
"task",
&serde_json::json!({"image_paths": ["picture.png"]}),
None,
diff --git a/crates/openhuman-core/src/agent/attachments/mod_tests.rs b/crates/openhuman-core/src/agent/attachments/mod_tests.rs
index 498362977d..37c9279807 100644
--- a/crates/openhuman-core/src/agent/attachments/mod_tests.rs
+++ b/crates/openhuman-core/src/agent/attachments/mod_tests.rs
@@ -318,6 +318,7 @@ async fn hard_zero_and_count_gate_precede_reads() {
#[tokio::test]
async fn vision_without_explicit_references_fails_before_configuration_or_inference() {
assert!(!has_resolvable_image(
+ &crate::core::runtime::DispatchCtx::ambient(),
"Describe a filename mentioned only in prose: picture.png",
None,
None
@@ -325,6 +326,7 @@ async fn vision_without_explicit_references_fails_before_configuration_or_infere
.await
.unwrap());
assert!(delegation_prompt(
+ &crate::core::runtime::DispatchCtx::ambient(),
"task",
&serde_json::json!({ "image_paths": [42] }),
None,
diff --git a/crates/openhuman-core/src/agent/multimodal_marker_extraction_tests.rs b/crates/openhuman-core/src/agent/multimodal_marker_extraction_tests.rs
index a44738b237..37c9b472fa 100644
--- a/crates/openhuman-core/src/agent/multimodal_marker_extraction_tests.rs
+++ b/crates/openhuman-core/src/agent/multimodal_marker_extraction_tests.rs
@@ -12,7 +12,7 @@ async fn prepare_messages_rejects_too_many_images() {
allow_remote_fetch: false,
};
- let error = prepare_messages_for_provider(&messages, &config, &MultimodalFileConfig::default())
+ let error = prepare_messages_for_provider(&crate::core::runtime::DispatchCtx::ambient(), &messages, &config, &MultimodalFileConfig::default())
.await
.expect_err("should reject image count overflow");
@@ -32,6 +32,7 @@ async fn prepare_messages_extracts_text_from_pdf() {
file_path.display()
))];
let prepared = prepare_messages_for_provider(
+ &crate::core::runtime::DispatchCtx::ambient(),
&messages,
&MultimodalConfig::default(),
&MultimodalFileConfig::default(),
@@ -65,7 +66,7 @@ async fn prepare_messages_rejects_oversized_file() {
..Default::default()
};
- let err = prepare_messages_for_provider(&messages, &MultimodalConfig::default(), &file_config)
+ let err = prepare_messages_for_provider(&crate::core::runtime::DispatchCtx::ambient(), &messages, &MultimodalConfig::default(), &file_config)
.await
.expect_err("oversized file must be rejected");
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_approval_guard_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_approval_guard_tests.rs
index 74b6d86520..b02e7b5298 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_approval_guard_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_approval_guard_tests.rs
@@ -69,10 +69,10 @@ async fn desktop_external_effect_inner() {
assert!(middleware.has_external_effect("desktop_goal", &json!({})));
assert!(
!middleware
- .requires_approval("desktop_goal", &json!({}))
+ .requires_approval(&crate::core::runtime::DispatchCtx::ambient(), "desktop_goal", &json!({}))
.await
);
- assert!(middleware.requires_approval("send_email", &json!({})).await);
+ assert!(middleware.requires_approval(&crate::core::runtime::DispatchCtx::ambient(), "send_email", &json!({})).await);
match previous {
Some(value) => unsafe { std::env::set_var("OPENHUMAN_WORKSPACE", value) },
None => unsafe { std::env::remove_var("OPENHUMAN_WORKSPACE") },
diff --git a/crates/openhuman-core/src/tools/impl/network/host_tests.rs b/crates/openhuman-core/src/tools/impl/network/host_tests.rs
index c19fa4b5c3..b943890e89 100644
--- a/crates/openhuman-core/src/tools/impl/network/host_tests.rs
+++ b/crates/openhuman-core/src/tools/impl/network/host_tests.rs
@@ -5,6 +5,7 @@ use tinytools::Tool;
fn fetch() -> WebFetchTool {
web_fetch_tool(
+ &crate::core::runtime::DispatchCtx::ambient(),
Arc::new(SecurityPolicy::default()),
vec!["example.com".into()],
None,
@@ -92,12 +93,19 @@ async fn tinyjuice_detects_and_converts_html() {
return;
}
let page = "<!DOCTYPE html><html><body><p>hi</p></body></html>";
- assert!(TinyJuiceHtml.looks_like_html(page).await.unwrap());
- assert!(!TinyJuiceHtml
+ assert!(TinyJuiceHtml {
+ ctx: crate::core::runtime::DispatchCtx::ambient(),
+ }
+ .looks_like_html(page).await.unwrap());
+ assert!(!TinyJuiceHtml {
+ ctx: crate::core::runtime::DispatchCtx::ambient(),
+ }
.looks_like_html("# Just a README\n\nSome prose.\n")
.await
.unwrap());
- assert!(TinyJuiceHtml
+ assert!(TinyJuiceHtml {
+ ctx: crate::core::runtime::DispatchCtx::ambient(),
+ }
.to_markdown(page)
.await
.unwrap()