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(tinyagents): update registry tests for accessor-based definitions
Steven Enamakelf4eecbfb6ca0
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/definition_registry_tests.rs b/crates/openhuman-core/src/agent/tinyagents/host/definition_registry_tests.rsindex 5ac2e744a1..2404cde71b 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/definition_registry_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/definition_registry_tests.rs@@ -1,4 +1,16 @@use super::*;++trait ProjectedToolNames {+ fn names(&self) -> Vec<String>;+}+impl ProjectedToolNames for tinyagents_definition::ToolScope {+ fn names(&self) -> Vec<String> {+ match self {+ Self::Named(names) => names.clone(),+ Self::Wildcard => panic!("host projection must remain explicit"),+ }+ }+}use crate::agent::registry::types::{AgentRegistryEntry, AgentRegistrySource, AgentSubagentPolicy};fn builtins() -> OpenHumanDefinitionRegistry {@@ -133,7 +145,7 @@ async fn a_worker_parent_authorizes_nothing() {.await.expect("resolve").expect("leaf exists");- assert_eq!(def.subagents, vec!["a_worker".to_string()]);+ assert_eq!(def.allowed_subagent_ids(), vec!["a_worker".to_string()]);}#[tokio::test]@@ -181,9 +193,9 @@ async fn orchestrator_projects_its_identity_fields() {.expect("resolve").expect("the orchestrator is always a built-in");assert_eq!(def.id, "orchestrator");- assert!(!def.name.is_empty());+ assert!(!def.display_name().is_empty());assert!(- !def.description.is_empty(),+ !def.when_to_use.is_empty(),"description is the delegating parent's capability summary");assert!(@@ -191,7 +203,7 @@ async fn orchestrator_projects_its_identity_fields() {"the orchestrator declares delegates");assert!(- !def.tools.is_empty(),+ !def.tools.names().is_empty(),"the orchestrator has a named tool scope");}@@ -249,7 +261,8 @@ fn an_undenied_wildcard_scope_projects_registered_tools() {registry_of(vec![def.clone()]).with_registered_tools(Arc::new(vec!["file_read".to_string()])).project(&def)- .tools,+ .tools+ .names(),vec!["file_read".to_string()]);}@@ -262,14 +275,14 @@ fn named_tool_search_grants_deferred_tools_to_hosted_run() {"desktop_list_apps".to_owned(),"desktop_goal".to_owned(),]));- let tools = registry.project(&with_search).tools;+ let tools = registry.project(&with_search).tools.names();assert!(tools.iter().any(|name| name == "tool_search"));assert!(tools.iter().any(|name| name == "desktop_list_apps"));assert!(tools.iter().any(|name| name == "desktop_goal"));let mut without_search = synthetic("no-search", AgentTier::Chat, &[]);without_search.tools = ToolScope::Named(vec!["file_read".to_owned()]);- let tools = registry.project(&without_search).tools;+ let tools = registry.project(&without_search).tools.names();assert!(!tools.iter().any(|name| name.starts_with("desktop_")));}@@ -285,9 +298,15 @@ fn named_discovery_scope_authorizes_only_registered_deferred_tools() {"blocked_secret".into(),])).project(&def);- assert!(projected.tools.contains(&"browser_open".to_string()));- assert!(projected.tools.contains(&"browser".to_string()));- assert!(!projected.tools.contains(&"blocked_secret".to_string()));+ assert!(projected+ .tools+ .names()+ .contains(&"browser_open".to_string()));+ assert!(projected.tools.names().contains(&"browser".to_string()));+ assert!(!projected+ .tools+ .names()+ .contains(&"blocked_secret".to_string()));def.tools = ToolScope::Named(vec!["file_read".into()]);let without_discovery = registry_of(vec![def.clone()])@@ -295,6 +314,7 @@ fn named_discovery_scope_authorizes_only_registered_deferred_tools() {.project(&def);assert!(!without_discovery.tools+ .names().contains(&"browser_open".to_string()));}@@ -319,9 +339,9 @@ fn a_wildcard_denylist_is_materialized_against_the_registered_tools() {])).project(&def);- assert_eq!(projected.tools, vec!["file_read".to_string()]);+ assert_eq!(projected.tools.names(), vec!["file_read".to_string()]);assert!(- !projected.tools.iter().any(|t| t == "secret_read"),+ !projected.tools.names().iter().any(|t| t == "secret_read"),"a denied tool must not survive the wildcard projection");}@@ -337,7 +357,7 @@ fn a_wildcard_denylist_without_registered_tools_fails_closed() {let projected = registry_of(vec![def.clone()]).project(&def);assert_eq!(- projected.tools,+ projected.tools.names(),vec![NO_TOOLS_SENTINEL.to_string()],"an unexpressible denylist must not read back as 'all tools'");@@ -352,7 +372,7 @@ fn an_explicitly_tool_less_named_scope_projects_the_no_tools_sentinel() {def.extra_tools = Vec::new();assert_eq!(- registry_of(vec![def.clone()]).project(&def).tools,+ registry_of(vec![def.clone()]).project(&def).tools.names(),vec![NO_TOOLS_SENTINEL.to_string()]);}@@ -366,7 +386,7 @@ fn a_named_scope_emptied_by_its_denylist_projects_the_no_tools_sentinel() {def.disallowed_tools = vec!["example_tool".to_string()];assert_eq!(- registry_of(vec![def.clone()]).project(&def).tools,+ registry_of(vec![def.clone()]).project(&def).tools.names(),vec![NO_TOOLS_SENTINEL.to_string()]);}@@ -380,7 +400,7 @@ fn named_scope_drops_denied_tools_and_keeps_extras() {let registry = registry_of(vec![def.clone()]);assert_eq!(- registry.project(&def).tools,+ registry.project(&def).tools.names(),vec!["file_read".to_string(), "grep".to_string()]);}@@ -444,9 +464,9 @@ async fn an_enabled_custom_config_agent_resolves_and_lists() {.await.expect("resolve").expect("an enabled custom agent is in the catalogue");- assert_eq!(def.name, "Finance Analyst");- assert_eq!(def.model.as_deref(), Some("hint:reasoning"));- assert_eq!(def.tools, vec!["memory_recall".to_string()]);+ assert_eq!(def.display_name(), "Finance Analyst");+ assert_eq!(def.model.pin().as_deref(), Some("hint:reasoning"));+ assert_eq!(def.tools.names(), vec!["memory_recall".to_string()]);let listed = registry.list().await.expect("list");assert_eq!(@@ -476,7 +496,11 @@ async fn a_harness_definition_shadows_a_same_id_config_entry() {.await.expect("resolve").expect("present");- assert_eq!(def.name, "finance display", "harness definition must win");+ assert_eq!(+ def.display_name(),+ "finance display",+ "harness definition must win"+ );assert_eq!(registry.list().await.expect("list").len(), 1);}@@ -559,7 +583,8 @@ async fn the_sessions_own_definition_outranks_a_same_id_registry_entry() {// `project` maps `name` from `display_name()`, which only the caller's copy// sets — had the registry entry won, this would be its own display name.assert_eq!(- resolved.name, "the caller's own",+ resolved.display_name(),+ "the caller's own","the session's own definition must win over the same-id registry entry");// And the tier travels with it: the registry entry is Chat-tier (what the@@ -620,7 +645,8 @@ fn named_scope_admits_the_tinyjuice_tools_a_handle_names() {.with_config(handle_mode_config()).with_registered_tools(registered).project(&def)- .tools;+ .tools+ .names();for name in ["juice_retrieve","juice_find",@@ -647,7 +673,8 @@ fn named_scope_skips_tinyjuice_tools_that_are_off_or_unregistered() {.with_config(Arc::new(off)).with_registered_tools(Arc::new(vec!["file_read".into(), "juice_find".into()])).project(&def)- .tools;+ .tools+ .names();assert!(!tools.contains(&"juice_find".to_string()), "{tools:?}");// Active but not registered: an allowlist entry for a tool that does not@@ -656,7 +683,8 @@ fn named_scope_skips_tinyjuice_tools_that_are_off_or_unregistered() {.with_config(handle_mode_config()).with_registered_tools(Arc::new(vec!["file_read".into()])).project(&def)- .tools;+ .tools+ .names();assert!(!tools.contains(&"juice_find".to_string()), "{tools:?}");}@@ -668,6 +696,7 @@ fn zero_tool_scope_stays_zero_tool_with_tinyjuice_active() {.with_config(handle_mode_config()).with_registered_tools(Arc::new(vec!["juice_find".into()])).project(&def)- .tools;+ .tools+ .names();assert!(!tools.contains(&"juice_find".to_string()), "{tools:?}");}