Skip to content

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

fix(embed): honor withheld discovery tool

Steven Enamakel5dd0ad6b0d78
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.rs
index 5f3352c90b..19694f5613 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
@@ -142,7 +142,10 @@ impl SessionHostBuilder {
// that is still empty — see the matching strip there.
let discovery_opted_in =
visible_names.remove(crate::tools::implementations::meta::TOOL_SEARCH_NAME);
- let discovery_enabled = belt_is_wildcard || discovery_opted_in;
+ let discovery_enabled = (belt_is_wildcard || discovery_opted_in)
+ && !self
+ .withheld_tool_names
+ .contains(crate::tools::implementations::meta::TOOL_SEARCH_NAME);
// A wildcard belt was seeded from the whole registry, so its durable
// `Hidden` members (collapsed `memory_*` / `todo_*`) leave here too.
// A named belt never listed them.
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs
index 415d7dadce..c16bcb7f25 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs
@@ -120,6 +120,31 @@ fn a_host_can_withhold_a_config_tool_for_one_turn() {
);
}
+#[test]
+fn withholding_tool_search_disables_wildcard_discovery() {
+ let tmp = tempfile::TempDir::new().unwrap();
+ let config = test_config(&tmp);
+ let host: crate::agent::HostTools = Arc::new(|_| crate::agent::HostTurnTools {
+ withheld: std::collections::HashSet::from([
+ crate::tools::implementations::meta::TOOL_SEARCH_NAME.to_string(),
+ ]),
+ ..Default::default()
+ });
+
+ let agent = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
+ &config,
+ &definition(),
+ &host,
+ None,
+ )
+ .expect("build a wildcard session with discovery withheld");
+
+ assert!(
+ agent.deferred_tool_names_for_test().is_empty(),
+ "withholding tool_search must also make deferred tools unreachable"
+ );
+}
+
/// Without this the seam would be a belt, not a factory, and a host whose
/// tools belong to something shorter-lived than the agent -- one episode, one
/// room -- would have to register a second agent to express that. It is also