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(attachments): cover provider wrapper turn context lifetime
Steven Enamakelb1c215bbe163
diff --git a/crates/openhuman-core/src/agent/harness/graph.rs b/crates/openhuman-core/src/agent/harness/graph.rsindex 29ab4c31b3..a3eafc8f8e 100644--- a/crates/openhuman-core/src/agent/harness/graph.rs+++ b/crates/openhuman-core/src/agent/harness/graph.rs@@ -122,6 +122,7 @@ pub(crate) async fn run_channel_turn_via_graph(Some(crate::security::turn_origin::AgentTurnOrigin::ExternalChannel { .. })),workspace: workspace.clone(),+ ..Default::default()};row.content =crate::attachments::stage(&row.content, "channel", config, &scope).await?;diff --git a/crates/openhuman-core/src/attachments/mod.rs b/crates/openhuman-core/src/attachments/mod.rsindex ff6f0d6702..7c7c94fb46 100644--- a/crates/openhuman-core/src/attachments/mod.rs+++ b/crates/openhuman-core/src/attachments/mod.rs@@ -475,6 +475,7 @@ pub(crate) async fn delegation_prompt(let scope = AttachmentAccessScope {external_channel: false,workspace: workspace.map(|workspace| workspace.root.clone()),+ mime_hints: Default::default(),};stage(&prompt, "delegation", &config, &scope).await}@@ -513,6 +514,7 @@ pub(crate) async fn has_resolvable_image(let scope = AttachmentAccessScope {external_channel: false,workspace: workspace.map(|workspace| workspace.root.clone()),+ mime_hints: Default::default(),};for path in paths {let path = legacy::migrate_path(&config, &path, &scope)@@ -610,6 +612,7 @@ pub(crate) async fn stage_turn(Some(crate::security::turn_origin::AgentTurnOrigin::ExternalChannel { .. })),workspace: workspace.map(|workspace| workspace.root.clone()),+ mime_hints: Default::default(),};stage(message, thread.unwrap_or("direct"), &config, &scope).await}diff --git a/crates/openhuman-core/src/attachments/mod_access_tests.rs b/crates/openhuman-core/src/attachments/mod_access_tests.rsindex 06489961d9..d52202c6b1 100644--- a/crates/openhuman-core/src/attachments/mod_access_tests.rs+++ b/crates/openhuman-core/src/attachments/mod_access_tests.rs@@ -199,6 +199,7 @@ async fn thread_folder_upload_is_staged_where_the_turn_reads_it() {&AttachmentAccessScope {external_channel: false,workspace: Some(root),+ ..Default::default()},).awaitdiff --git a/crates/openhuman-core/src/attachments/mod_tests.rs b/crates/openhuman-core/src/attachments/mod_tests.rsindex b14493988b..8e4b82a08e 100644--- a/crates/openhuman-core/src/attachments/mod_tests.rs+++ b/crates/openhuman-core/src/attachments/mod_tests.rs@@ -58,6 +58,7 @@ async fn legacy_migration_does_not_grant_private_file_or_disabled_image_access()let external_scope = AttachmentAccessScope {external_channel: true,workspace: None,+ ..Default::default()};assert!(legacy::migrate_from(&cfg, source.to_str().unwrap(), &stash, &external_scope)@@ -412,6 +413,7 @@ async fn explicit_workspace_wins_over_config_action_dir() {let scope = AttachmentAccessScope {external_channel: false,workspace: Some(scoped.clone()),+ ..Default::default()};let attachment = save(&config, "thread", "file", "text/plain", b"original", &scope).awaitdiff --git a/crates/openhuman-core/src/attachments/provider_context_tests.rs b/crates/openhuman-core/src/attachments/provider_context_tests.rsindex 964021c196..0ee4e786d8 100644--- a/crates/openhuman-core/src/attachments/provider_context_tests.rs+++ b/crates/openhuman-core/src/attachments/provider_context_tests.rs@@ -18,3 +18,21 @@ async fn the_wrapped_model_keeps_its_turns_context_while_another_is_active() {assert!(Arc::ptr_eq(seen.core().expect("bound"), &turn));assert!(!Arc::ptr_eq(seen.core().expect("bound"), &other));}++#[test]+fn owner_media_wrapper_does_not_keep_a_turn_context_alive() {+ use crate::core::runtime::{CoreContext, DispatchCtx, DomainSet};+ let context = CoreContext::for_test(DomainSet::full(), None);+ let weak = Arc::downgrade(&context);+ let dispatch = DispatchCtx::new(Arc::clone(&context));+ let wrapper = owner::wrap(+ &dispatch,+ Arc::new(Probe::default()),+ Arc::new(Config::default()),+ ModelProfile::default(),+ );+ drop(dispatch);+ drop(context);+ assert!(weak.upgrade().is_none(), "the provider wrapper retains only weak turn context");+ drop(wrapper);+}diff --git a/crates/openhuman-core/src/attachments/provider_security_tests.rs b/crates/openhuman-core/src/attachments/provider_security_tests.rsindex 93f29809a0..4c38d40dda 100644--- a/crates/openhuman-core/src/attachments/provider_security_tests.rs+++ b/crates/openhuman-core/src/attachments/provider_security_tests.rs@@ -40,6 +40,7 @@ async fn secure_open_rejects_parent_symlink_replaced_after_path_validation() {let scope = AttachmentAccessScope {external_channel: false,workspace: Some(root.clone()),+ ..Default::default()};let validated = crate::attachments::resolve_path(&config, "nested/file.png", &scope).awaitdiff --git a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rsindex 67581ab99b..9deb01fcc6 100644--- a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs+++ b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs@@ -492,6 +492,7 @@ pub async fn agent_chat_reply_for(let scope = crate::attachments::AttachmentAccessScope {external_channel: false,workspace: turn_cwd.clone(),+ ..Default::default()};let references = crate::attachments::host::stage_host(attachments,diff --git a/crates/openhuman-core/src/threads/ops/crud.rs b/crates/openhuman-core/src/threads/ops/crud.rsindex 023d22feb4..f8561dfd78 100644--- a/crates/openhuman-core/src/threads/ops/crud.rs+++ b/crates/openhuman-core/src/threads/ops/crud.rs@@ -255,6 +255,7 @@ async fn message_append_with_config(Some(crate::security::turn_origin::AgentTurnOrigin::ExternalChannel { .. })),workspace: Some(workspace.clone()),+ ..Default::default()};let path = crate::attachments::resolve_path(config, &file.path, &scope).awaitdiff --git a/crates/openhuman-core/src/web_chat/ops/start_chat.rs b/crates/openhuman-core/src/web_chat/ops/start_chat.rsindex 8251e45ff4..7fa415f73c 100644--- a/crates/openhuman-core/src/web_chat/ops/start_chat.rs+++ b/crates/openhuman-core/src/web_chat/ops/start_chat.rs@@ -214,6 +214,7 @@ async fn start_chat_inner(&crate::attachments::AttachmentAccessScope {external_channel: false,workspace: Some(workspace),+ ..Default::default()},).await