Skip to content

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

test(agent_runs): cover cache key isolation by role and workspace

Steven Enamakele33238ed9450
diff --git a/crates/openhuman-core/src/agent_runs/context_breakdown_tests.rs b/crates/openhuman-core/src/agent_runs/context_breakdown_tests.rs
index ba1adfb5c8..6c8ce23cac 100644
--- a/crates/openhuman-core/src/agent_runs/context_breakdown_tests.rs
+++ b/crates/openhuman-core/src/agent_runs/context_breakdown_tests.rs
@@ -98,9 +98,37 @@ fn report_cache_key_isolated_by_tenant_even_for_identical_config() {
assert_eq!(config_fingerprint(&config), config_fingerprint(&config));
assert_ne!(
- report_cache_key(alice, "orchestrator", &config),
+ report_cache_key(alice.clone(), "orchestrator", &config),
report_cache_key(bob, "orchestrator", &config),
);
+ assert_ne!(
+ report_cache_key(alice.clone(), "orchestrator", &config),
+ report_cache_key(alice.clone(), "delegate", &config),
+ );
+ let mut other_workspace = config.clone();
+ other_workspace.workspace_dir = std::path::PathBuf::from("/tmp/other-workspace");
+ assert_eq!(
+ config_fingerprint(&config),
+ config_fingerprint(&other_workspace),
+ "runtime workspace paths are not part of serialized config"
+ );
+ assert_ne!(
+ report_cache_key(alice.clone(), "orchestrator", &config),
+ report_cache_key(alice, "orchestrator", &other_workspace),
+ );
+ let mut other_config_path = config.clone();
+ other_config_path.config_path = std::path::PathBuf::from("/tmp/other-config.toml");
+ assert_ne!(
+ report_cache_key(tenant_for_test("alice"), "orchestrator", &config),
+ report_cache_key(tenant_for_test("alice"), "orchestrator", &other_config_path),
+ );
+}
+
+fn tenant_for_test(profile: &str) -> crate::core::runtime::Tenant {
+ crate::core::runtime::Tenant {
+ profile: Some(profile.into()),
+ agent: None,
+ }
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/memory/lifecycle/session_hooks.rs b/crates/openhuman-core/src/memory/lifecycle/session_hooks.rs
index 044674ee02..f001014071 100644
--- a/crates/openhuman-core/src/memory/lifecycle/session_hooks.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/session_hooks.rs
@@ -319,5 +319,5 @@ fn committed_tool_calls(history: &[Message]) -> Vec<ToolCallSummary> {
}
#[cfg(test)]
-#[path = "memory_ingest_tests.rs"]
+#[path = "session_hooks_tests.rs"]
mod tests;