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(agent): cover catalogue resolution through the agent context (#7032)
oxoxDevc2915e88a9f8
diff --git a/crates/openhuman-core/src/agent/harness/definition/registry.rs b/crates/openhuman-core/src/agent/harness/definition/registry.rsindex f1e67ea27b..0355f88481 100644--- a/crates/openhuman-core/src/agent/harness/definition/registry.rs+++ b/crates/openhuman-core/src/agent/harness/definition/registry.rs@@ -173,3 +173,7 @@ impl AgentDefinitionRegistry {registry}}++#[cfg(test)]+#[path = "registry_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/agent/harness/definition/registry_tests.rs b/crates/openhuman-core/src/agent/harness/definition/registry_tests.rsnew file mode 100644index 0000000000..c8165a375a--- /dev/null+++ b/crates/openhuman-core/src/agent/harness/definition/registry_tests.rs@@ -0,0 +1,55 @@+use super::*;+use crate::core::runtime::{ContextOverlay, CoreContext, DomainSet};++fn named(id: &str, when: &str) -> AgentDefinition {+ let mut definition = AgentDefinitionRegistry::builtins_only()+ .get("orchestrator")+ .cloned()+ .expect("built-in orchestrator");+ definition.id = id.to_string();+ definition.when_to_use = when.to_string();+ definition+}++#[test]+fn with_definitions_adds_and_replaces_without_touching_the_source() {+ let base = AgentDefinitionRegistry::builtins_only();+ let before = base.len();+ let own = base.with_definitions([+ named("own-worker", "added"),+ named("orchestrator", "replaced"),+ ]);+ assert_eq!(own.len(), before + 1);+ assert_eq!(own.get("own-worker").unwrap().when_to_use, "added");+ assert_eq!(own.get("orchestrator").unwrap().when_to_use, "replaced");+ assert!(base.get("own-worker").is_none());+ assert_ne!(base.get("orchestrator").unwrap().when_to_use, "replaced");+}++#[tokio::test]+async fn current_follows_the_agent_context_and_falls_back_to_the_process() {+ let own = Arc::new(+ AgentDefinitionRegistry::builtins_only().with_definitions([named("ctx-only", "mine")]),+ );+ let parent = CoreContext::for_test(DomainSet::full(), Some(std::env::temp_dir()));+ let agent = parent.derive_with(+ ContextOverlay::new(+ crate::config::Config::default(),+ DomainSet::kernel(),+ crate::tools::toolpacks::ToolGroups::none(),+ )+ .session_agent("catalogue-agent")+ .definitions(Arc::clone(&own)),+ );++ let seen = CoreContext::scope(agent, async { AgentDefinitionRegistry::current() })+ .await+ .expect("the agent's registry");+ assert!(Arc::ptr_eq(&seen, &own));++ let outside = CoreContext::scope(parent, async { AgentDefinitionRegistry::current() }).await;+ assert!(+ outside.is_none_or(|registry| registry.get("ctx-only").is_none()),+ "a context without its own catalogue resolves through the process"+ );+}