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
fix(embed): apply withheld names after scope expansion
Steven Enamakele62a3e01fd06
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_build.rsindex f590873f5c..5f3352c90b 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs@@ -177,6 +177,14 @@ impl SessionHostBuilder {"[tools] withheld deferred tool schemas; reachable via the harness tool_search bridge");}+ if !self.withheld_tool_names.is_empty() {+ visible_names.retain(|name| !self.withheld_tool_names.contains(name));+ deferred_names.retain(|name| !self.withheld_tool_names.contains(name));+ if visible_names.is_empty() {+ visible_names+ .insert(crate::agent::harness::definition::NO_TOOLS_SENTINEL.to_string());+ }+ }// What the policy classifies and the harness registers: the advertised// set plus the deferred set. A deferred tool outside this union would// be `HideFromPrompt`, and the direct-call gate refuses those.diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rsindex 95c35e28df..1af5e90bec 100644--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs@@ -980,14 +980,18 @@ impl OpenHumanSessionHost {}// Host-first, so a host tool wins a name collision -- see// `HostTurnTools::merge_into`, which owns that rule and why.- let host_policy = host+ let merged_host_tools = host.map(|build| build(super::host_tools::TurnContext::new(agent_id, session_id))).and_then(|host_tools| host_tools.merge_into(agent_id, &mut tools, &mut visible));+ let (host_policy, withheld_tool_names) = merged_host_tools+ .map(|merged| (merged.policy, merged.withheld))+ .unwrap_or_default();let mut builder = OpenHumanSessionHost::builder().crate_native_provider(provider_role, Arc::clone(&base_config)).tools(tools).synthesized_tools(delegation_tools).visible_tool_names(visible)+ .withheld_tool_names(withheld_tool_names).deferred_tools(target_def.map_or_else(Vec::new, |d| d.deferred_tools.clone())).memory(memory).auto_recall(Some(auto_recall))diff --git a/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs b/crates/openhuman-core/src/agent/session_host/builder/host_tools.rsindex 67c054a185..8f195d9b68 100644--- a/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs@@ -53,7 +53,8 @@ pub struct HostTurnTools {/// This is applied after the config-derived scope and `visible` names are/// combined, so a host can hide a tool that the agent normally receives/// without changing the agent's scope for other turns. Withheld tools- /// remain registered and their execution policy is unchanged.+ /// remain in the registry; hosts that require a call boundary must also+ /// enforce one through the session's tool policy.pub withheld: HashSet<String>,/// The session's admission gate, if the host sets one.pub policy: Option<Arc<dyn ToolPolicy>>,@@ -97,9 +98,12 @@ impl HostTurnTools {agent_id: &str,tools: &mut Vec<Box<dyn Tool>>,visible: &mut HashSet<String>,- ) -> Option<Arc<dyn ToolPolicy>> {+ ) -> MergedHostTurnTools {if self.is_empty() {- return None;+ return MergedHostTurnTools {+ policy: None,+ withheld: HashSet::new(),+ };}log::debug!("[agent::builder] host supplied {} tool(s) for agent_id={agent_id}: {:?}",@@ -111,8 +115,10 @@ impl HostTurnTools {);tools.splice(0..0, self.tools);visible.extend(self.visible);- visible.retain(|name| !self.withheld.contains(name));- self.policy+ MergedHostTurnTools {+ policy: self.policy,+ withheld: self.withheld,+ }}/// Sets the gate for the whole session.@@ -145,6 +151,13 @@ impl HostTurnTools {}}+/// The parts of a host turn belt that the session builder applies after+/// expanding the agent's static scope.+pub(super) struct MergedHostTurnTools {+ pub policy: Option<Arc<dyn ToolPolicy>>,+ pub withheld: HashSet<String>,+}+impl std::fmt::Debug for HostTurnTools {fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {f.debug_struct("HostTurnTools")diff --git a/crates/openhuman-core/src/agent/session_host/builder/setters.rs b/crates/openhuman-core/src/agent/session_host/builder/setters.rsindex f9703ed259..819a584d98 100644--- a/crates/openhuman-core/src/agent/session_host/builder/setters.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/setters.rs@@ -16,6 +16,7 @@ impl SessionHostBuilder {tools: None,synthesized_tools: None,visible_tool_names: None,+ withheld_tool_names: std::collections::HashSet::new(),deferred_tools: Vec::new(),subagent_tool_ceiling_names: None,memory: None,@@ -99,6 +100,13 @@ impl SessionHostBuilder {self}+ /// Removes these names from the final provider-visible tool set after the+ /// agent's static scope and synthesized tools have been expanded.+ pub fn withheld_tool_names(mut self, names: std::collections::HashSet<String>) -> Self {+ self.withheld_tool_names = names;+ self+ }+/// Tools to take off this agent's wire and serve through `tool_search`/// instead (the definition's `deferred_tools`). Applies only to a belt/// that opted into discovery; see `meta::deferred_set`.diff --git a/crates/openhuman-core/src/agent/session_host/types.rs b/crates/openhuman-core/src/agent/session_host/types.rsindex af70344734..7e9d32b029 100644--- a/crates/openhuman-core/src/agent/session_host/types.rs+++ b/crates/openhuman-core/src/agent/session_host/types.rs@@ -549,6 +549,9 @@ pub struct SessionHostBuilder {pub(super) synthesized_tools: Option<Vec<Box<dyn Tool>>>,/// When set, restricts which tools the main agent sees/calls.pub(super) visible_tool_names: Option<std::collections::HashSet<String>>,+ /// Names removed from the final provider-visible set after wildcard+ /// expansion and tool synthesis.+ pub(super) withheld_tool_names: std::collections::HashSet<String>,/// See [`SessionHostBuilder::deferred_tools`].pub(super) deferred_tools: Vec<String>,/// Optional explicit profile ceiling for tools delegated agents may inherit.