Skip to content

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

fix(embed): apply host withholding after expansion

Steven Enamakel95f034fc77a3
diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
index 1af5e90bec..a27ab436ed 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
@@ -980,12 +980,8 @@ impl OpenHumanSessionHost {
}
// Host-first, so a host tool wins a name collision -- see
// `HostTurnTools::merge_into`, which owns that rule and why.
- 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 (host_policy, withheld_tool_names) =
+ super::host_tools::merge_for_turn(host, agent_id, session_id, &mut tools, &mut visible);
let mut builder = OpenHumanSessionHost::builder()
.crate_native_provider(provider_role, Arc::clone(&base_config))
.tools(tools)
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.rs
index 8f195d9b68..f1aa04415f 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
@@ -158,6 +158,22 @@ pub(super) struct MergedHostTurnTools {
pub withheld: HashSet<String>,
}
+pub(super) fn merge_for_turn(
+ host: Option<&HostTools>,
+ agent_id: &str,
+ session_id: Option<&str>,
+ tools: &mut Vec<Box<dyn Tool>>,
+ visible: &mut HashSet<String>,
+) -> (Option<Arc<dyn ToolPolicy>>, HashSet<String>) {
+ match host
+ .map(|build| build(TurnContext::new(agent_id, session_id)))
+ .map(|host_tools| host_tools.merge_into(agent_id, tools, visible))
+ {
+ Some(merged) => (merged.policy, merged.withheld),
+ None => (None, HashSet::new()),
+ }
+}
+
impl std::fmt::Debug for HostTurnTools {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("HostTurnTools")