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
refactor(tinyagents): project host definitions onto portable tool and model scopes
Steven Enamakeld637130603b5
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_session_definition_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_session_definition_tests.rsindex 2dc93e5a96..7f8bec15b7 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_session_definition_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_session_definition_tests.rs@@ -79,7 +79,7 @@ async fn a_definition_the_builder_was_given_resolves_for_the_turn() {.expect("the caller's own definition answers the lookup");assert_eq!(resolved.id, SEAT);- assert_eq!(resolved.name, "Library host seat");+ assert_eq!(resolved.display_name(), "Library host seat");assert!(resolved.is_valid(),"a hosted turn refuses an invalid definition: {:?}",@@ -100,7 +100,10 @@ async fn the_definition_carries_the_belt_the_turn_is_allowed_to_call() {.expect("resolution never errors").expect("resolves");- assert_eq!(resolved.tools, vec!["desk_say", "publish_artifact"]);+ assert_eq!(+ resolved.tools,+ tinyagents_definition::ToolScope::Named(vec!["desk_say".into(), "publish_artifact".into()])+ );}#[tokio::test]@@ -121,8 +124,11 @@ async fn the_sessions_own_definition_outranks_a_registry_entry_sharing_its_id().expect("resolution never errors").expect("resolves");- assert_eq!(resolved.name, "Library host seat");- assert_eq!(resolved.tools, vec!["desk_say"]);+ assert_eq!(resolved.display_name(), "Library host seat");+ assert_eq!(+ resolved.tools,+ tinyagents_definition::ToolScope::Named(vec!["desk_say".into()])+ );}#[tokio::test]diff --git a/crates/openhuman-core/src/agent/tinyagents/host/bundle_tests.rs b/crates/openhuman-core/src/agent/tinyagents/host/bundle_tests.rsindex 7be23eca1e..e6af7206a0 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/bundle_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/bundle_tests.rs@@ -100,5 +100,7 @@ async fn hosted_orchestrator_allows_deferred_browser_discovery() {.await.expect("resolve").expect("orchestrator");- assert!(definition.tools.contains(&"browser_open".to_string()));+ assert!(+ matches!(definition.tools, tinyagents_definition::ToolScope::Named(names) if names.contains(&"browser_open".to_string()))+ );}diff --git a/crates/openhuman-core/src/agent/tinyagents/host/definition_registry.rs b/crates/openhuman-core/src/agent/tinyagents/host/definition_registry.rsindex b469fedc0f..5b3aa5cc87 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/definition_registry.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/definition_registry.rs@@ -38,25 +38,12 @@//! ids are **kept**, matching both [`validate_tier_hierarchy`](crate::agent::registry::agents::validate_tier_hierarchy)'s `continue` and//! the trait's note that an authorized id may still fail to resolve.//!-//! **3. `ToolScope::Wildcard` has no crate representation.** The crate models-//! tools as an explicit `Vec<String>` in which **empty means unrestricted**,-//! matching the session builder ("an empty `visible` set means no filter" —-//! `agent/session_host/builder/factory.rs`). So an unrestricted wildcard-//! agent maps to an empty `tools` vec.-//!-//! That one value must not be made to carry three meanings. Three distinct-//! situations would otherwise all collapse onto "empty", and each would read-//! back as *every tool*:-//!-//! * a named scope configured with **no** tools,-//! * a named scope whose every entry the denylist removed,-//! * a wildcard scope carrying a denylist the crate cannot express.-//!-//! [`ResolvedScope`] therefore models wildcard-ness explicitly and never infers-//! it from emptiness. A genuinely empty scope emits-//! [`NO_TOOLS_SENTINEL`] — an unregistered name that matches nothing —-//! and a wildcard-with-denylist is materialized against-//! [`Self::with_registered_tools`], failing closed when that is absent.+//! **3. Tool scopes remain host-materialized.** The portable definition+//! carries an explicit named scope, after the host applies discovery,+//! companion-tool and denylist policy. Wildcards are materialized against+//! [`Self::with_registered_tools`] and fail closed when no catalogue exists.+//! Empty scopes retain [`NO_TOOLS_SENTINEL`] for compatibility with the host's+//! existing tool visibility contract; they never become portable wildcards.//!//! **4. `SubagentEntry::Skills` entries are omitted.** A `{ skills = "*" }`//! entry is not an agent id — it expands to the connected integrations'@@ -293,21 +280,25 @@ impl OpenHumanDefinitionRegistry {fn project(&self, def: &HostAgentDefinition) -> AgentDefinition {AgentDefinition {id: def.id.clone(),- name: def.display_name().to_string(),+ display_name: Some(def.display_name().to_string()),// `when_to_use` is exactly the trait's "capability summary shown to// a delegating parent" — the same string the harness feeds into a// synthesised `delegate_*` tool description.- description: def.when_to_use.clone(),+ when_to_use: def.when_to_use.clone(),// The definition's validated tier is the host assertion the model// resolver consumes for workload routing.role: Some(def.agent_tier.to_string()),model: model_for(&def.model),- subagents: declared_subagent_ids(def),- tools: self.tools_for(def),+ subagents: declared_subagent_ids(def)+ .into_iter()+ .map(tinyagents_definition::SubagentEntry::AgentId)+ .collect(),+ tools: tinyagents_definition::ToolScope::Named(self.tools_for(def)),// The definition's rule layer (its `tool_rules` plus its// `disallowed_tools` as a deny), enforced by the harness gate on// the catalogue, `tool_search` and every call of a hosted run.tool_rules: crate::tools::rules::agent_rule_layer(def),+ ..Default::default()}}@@ -472,17 +463,13 @@ fn declared_subagent_ids(def: &HostAgentDefinition) -> Vec<String> {.collect()}-/// Maps a host [`ModelSpec`] onto the crate's `Option<String>` model pin.-///-/// [`ModelSpec::Inherit`] becomes `None`, which is precisely the crate's "no-/// preference, the session default applies". `Hint` is resolved through-/// [`ModelSpec::resolve`] (whose `parent_model` argument is unused for the hint-/// arm) so the `hint:{hint}` alias spelling has one implementation.-fn model_for(spec: &ModelSpec) -> Option<String> {+/// Preserves inherited routing, concrete model pins and routing hints in the+/// provider-neutral definition vocabulary.+fn model_for(spec: &ModelSpec) -> tinyagents_definition::ModelSpec {match spec {- ModelSpec::Inherit => None,- ModelSpec::Exact(name) => Some(name.clone()),- ModelSpec::Hint(_) => Some(spec.resolve("")),+ ModelSpec::Inherit => tinyagents_definition::ModelSpec::Inherit,+ ModelSpec::Exact(name) => tinyagents_definition::ModelSpec::Exact(name.clone()),+ ModelSpec::Hint(hint) => tinyagents_definition::ModelSpec::Hint(hint.clone()),}}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 cd041fac66..b69e5d7563 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@@ -215,8 +215,14 @@ fn projected_model_preserves_inherit_exact_and_hint_routing() {use tinyagents_definition::ModelSpec as HarnessModel;for (model, expected) in [(ModelSpec::Inherit, HarnessModel::Inherit),- (ModelSpec::Exact("neocortex-mk1".into()), HarnessModel::Exact("neocortex-mk1".into())),- (ModelSpec::Hint("reasoning".into()), HarnessModel::Hint("reasoning".into())),+ (+ ModelSpec::Exact("neocortex-mk1".into()),+ HarnessModel::Exact("neocortex-mk1".into()),+ ),+ (+ ModelSpec::Hint("reasoning".into()),+ HarnessModel::Hint("reasoning".into()),+ ),] {let mut def = synthetic("routed", AgentTier::Worker, &[]);def.model = model;@@ -262,7 +268,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.named_tools(),+ .tools+ .named_tools(),vec!["file_read".to_string()]);}@@ -298,16 +305,26 @@ fn named_discovery_scope_authorizes_only_registered_deferred_tools() {"blocked_secret".into(),])).project(&def);- assert!(projected.tools.named_tools().contains(&"browser_open".to_string()));- assert!(projected.tools.named_tools().contains(&"browser".to_string()));- assert!(!projected.tools.named_tools().contains(&"blocked_secret".to_string()));+ assert!(projected+ .tools+ .named_tools()+ .contains(&"browser_open".to_string()));+ assert!(projected+ .tools+ .named_tools()+ .contains(&"browser".to_string()));+ assert!(!projected+ .tools+ .named_tools()+ .contains(&"blocked_secret".to_string()));def.tools = ToolScope::Named(vec!["file_read".into()]);let without_discovery = registry_of(vec![def.clone()]).with_deferred_tools(Arc::new(vec!["browser_open".into()])).project(&def);assert!(!without_discovery- .tools.named_tools()+ .tools+ .named_tools().contains(&"browser_open".to_string()));}@@ -334,7 +351,11 @@ fn a_wildcard_denylist_is_materialized_against_the_registered_tools() {assert_eq!(projected.tools.named_tools(), vec!["file_read".to_string()]);assert!(- !projected.tools.named_tools().iter().any(|t| t == "secret_read"),+ !projected+ .tools+ .named_tools()+ .iter()+ .any(|t| t == "secret_read"),"a denied tool must not survive the wildcard projection");}@@ -365,7 +386,10 @@ 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.named_tools(),+ registry_of(vec![def.clone()])+ .project(&def)+ .tools+ .named_tools(),vec![NO_TOOLS_SENTINEL.to_string()]);}@@ -379,7 +403,10 @@ 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.named_tools(),+ registry_of(vec![def.clone()])+ .project(&def)+ .tools+ .named_tools(),vec![NO_TOOLS_SENTINEL.to_string()]);}@@ -458,7 +485,7 @@ async fn an_enabled_custom_config_agent_resolves_and_lists() {.expect("resolve").expect("an enabled custom agent is in the catalogue");assert_eq!(def.display_name(), "Finance Analyst");- assert_eq!(def.model.as_deref(), Some("hint:reasoning"));+ assert_eq!(def.model.pin().as_deref(), Some("hint:reasoning"));assert_eq!(def.tools.named_tools(), vec!["memory_recall".to_string()]);let listed = registry.list().await.expect("list");@@ -489,7 +516,11 @@ async fn a_harness_definition_shadows_a_same_id_config_entry() {.await.expect("resolve").expect("present");- assert_eq!(def.display_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);}@@ -572,7 +603,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.display_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@@ -633,7 +665,8 @@ fn named_scope_admits_the_tinyjuice_tools_a_handle_names() {.with_config(handle_mode_config()).with_registered_tools(registered).project(&def)- .tools.named_tools();+ .tools+ .named_tools();for name in ["juice_retrieve","juice_find",@@ -660,7 +693,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.named_tools();+ .tools+ .named_tools();assert!(!tools.contains(&"juice_find".to_string()), "{tools:?}");// Active but not registered: an allowlist entry for a tool that does not@@ -669,7 +703,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.named_tools();+ .tools+ .named_tools();assert!(!tools.contains(&"juice_find".to_string()), "{tools:?}");}@@ -681,6 +716,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.named_tools();+ .tools+ .named_tools();assert!(!tools.contains(&"juice_find".to_string()), "{tools:?}");}