Skip to content

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

test(agent): cover per-agent sub-agent in-flight dedupe (#7032)

oxoxDeve65b176b60ea
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
index 6c886c2b06..6c3021223c 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
@@ -1306,3 +1306,7 @@ fn outcome_to_host(
fn map_lifecycle_error(error: SubagentError) -> SubagentRunError {
SubagentRunError::Provider(anyhow::anyhow!(error.to_string()))
}
+
+#[cfg(test)]
+#[path = "lifecycle_agent_tests.rs"]
+mod agent_tests;
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle_agent_tests.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle_agent_tests.rs
new file mode 100644
index 0000000000..bf6c359230
--- /dev/null
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle_agent_tests.rs
@@ -0,0 +1,17 @@
+use super::*;
+use crate::core::runtime::agent_scope::test_agent_context;
+use crate::core::runtime::{context::CoreContext, DomainSet};
+
+#[tokio::test]
+async fn each_agent_dedupes_its_own_in_flight_sub_agents() {
+ let root = CoreContext::for_test(DomainSet::full(), None);
+ let alpha = test_agent_context(&root, "alpha");
+ let beta = test_agent_context(&root, "beta");
+
+ let alpha_map = CoreContext::scope(Arc::clone(&alpha), async { host_in_flight() }).await;
+ let beta_map = CoreContext::scope(beta, async { host_in_flight() }).await;
+ let alpha_again = CoreContext::scope(alpha, async { host_in_flight() }).await;
+
+ assert!(!Arc::ptr_eq(&alpha_map, &beta_map));
+ assert!(Arc::ptr_eq(&alpha_map, &alpha_again));
+}