Skip to content

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

test(tests): add isolation and context checks to tests

Steven Enamakel171fe084af43
diff --git a/crates/openhuman-core/src/agent/goals/mod_tests.rs b/crates/openhuman-core/src/agent/goals/mod_tests.rs
index aa5f3c7717..aed1d5fd60 100644
--- a/crates/openhuman-core/src/agent/goals/mod_tests.rs
+++ b/crates/openhuman-core/src/agent/goals/mod_tests.rs
@@ -44,6 +44,39 @@ async fn goal_store_is_reused_within_a_context_and_isolated_between_agents() {
.is_none());
}
+#[tokio::test]
+async fn goal_store_isolated_between_profiles_with_the_same_agent_and_thread() {
+ use crate::core::runtime::{ContextOverlay, CoreContext, DispatchCtx, DomainSet};
+
+ let workspace = tempfile::tempdir().expect("workspace");
+ let context_for = |profile: &'static str| {
+ let overlay = ContextOverlay::new(
+ crate::config::Config::default(),
+ DomainSet::full(),
+ crate::tools::toolpacks::ToolGroups::none(),
+ )
+ .profile(profile)
+ .session_agent("same-agent");
+ CoreContext::for_test(DomainSet::full(), Some(workspace.path().to_path_buf()))
+ .derive_with(overlay)
+ };
+ let profile_a = DispatchCtx::new(context_for("profile-a"));
+ let profile_b = DispatchCtx::new(context_for("profile-b"));
+ let store_a = goal_store(workspace.path(), &profile_a);
+ let store_b = goal_store(workspace.path(), &profile_b);
+
+ assert!(!Arc::ptr_eq(&store_a, &store_b));
+ store_a
+ .set("shared-thread-id", "profile A objective", None)
+ .await
+ .expect("write profile A goal");
+ assert!(store_b
+ .get("shared-thread-id")
+ .await
+ .expect("read profile B goal")
+ .is_none());
+}
+
#[tokio::test]
async fn goal_tool_with_context_uses_the_business_goal_store() {
struct ThreadContext(&'static str);
diff --git a/crates/openhuman-core/src/artifacts/preview_tests.rs b/crates/openhuman-core/src/artifacts/preview_tests.rs
index e667008fdc..a71031da77 100644
--- a/crates/openhuman-core/src/artifacts/preview_tests.rs
+++ b/crates/openhuman-core/src/artifacts/preview_tests.rs
@@ -126,15 +126,17 @@ fn config_in(workspace: &Path) -> crate::config::Config {
async fn ids_that_name_another_file_are_refused() {
let workspace = tempfile::tempdir().unwrap();
let config = config_in(workspace.path());
+ let ctx = crate::core::runtime::DispatchCtx::process_default();
for id in ["../x", "a/b", "..", ".hidden"] {
- assert!(read_body(&config, id).await.is_err(), "{id:?}");
+ assert!(read_body(&config, id, &ctx).await.is_err(), "{id:?}");
}
}
#[tokio::test]
async fn an_unknown_artifact_is_not_found() {
let workspace = tempfile::tempdir().unwrap();
- let err = read_body(&config_in(workspace.path()), "missing")
+ let ctx = crate::core::runtime::DispatchCtx::process_default();
+ let err = read_body(&config_in(workspace.path()), "missing", &ctx)
.await
.unwrap_err();
assert!(err.contains("not found"), "{err}");
@@ -165,7 +167,8 @@ async fn an_artifact_made_before_versioning_opens_from_its_legacy_record() {
.await
.unwrap();
- let body = read_body(&config, &meta.id).await.unwrap();
+ let ctx = crate::core::runtime::DispatchCtx::process_default();
+ let body = read_body(&config, &meta.id, &ctx).await.unwrap();
assert_eq!(body.title, "Old notes");
assert_eq!(body.kind, "file");
assert_eq!(body.body, "# from before");