Skip to content

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

test(cron): assert bound context is dropped before expired callback runs

Steven Enamakelbcda9cbd880e
diff --git a/crates/openhuman-core/src/cron/bus_host_tests.rs b/crates/openhuman-core/src/cron/bus_host_tests.rs
index 2d787356a5..c6e48934d0 100644
--- a/crates/openhuman-core/src/cron/bus_host_tests.rs
+++ b/crates/openhuman-core/src/cron/bus_host_tests.rs
@@ -129,7 +129,15 @@ async fn an_expired_bound_callback_fails_closed_under_another_ambient_context()
let tmp = TempDir::new().unwrap();
let config = config(&tmp);
- let expired = CoreContext::for_test_with_config(DomainSet::full(), config.clone());
+ let expired = CoreContext::for_test_with_config(DomainSet::full(), config.clone()).derive_with(
+ ContextOverlay::new(
+ config.clone(),
+ DomainSet::full(),
+ crate::tools::toolpacks::ToolGroups::none(),
+ )
+ .session_agent(format!("expired-callback-{}", uuid::Uuid::new_v4().simple())),
+ );
+ let expired_weak = Arc::downgrade(&expired);
let dispatch = DispatchCtx::new(Arc::clone(&expired));
let security = Arc::new(SecurityPolicy::from_config(
&config.autonomy,
@@ -143,6 +151,7 @@ async fn an_expired_bound_callback_fails_closed_under_another_ambient_context()
};
drop(dispatch);
drop(expired);
+ assert!(expired_weak.upgrade().is_none(), "the bound context is truly expired before the callback");
let other = CoreContext::for_test_with_config(DomainSet::full(), config.clone()).derive_with(
ContextOverlay::new(