Skip to content

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

test: add deferred tool reachability coverage for wildcard belts

Steven Enamakel8acedaad6ad4
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs
index f7b3e94b2d..a9e4554fd6 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs
@@ -72,11 +72,7 @@ fn hiding_and_reseeding_wildcard_visibility_keeps_collapsed_exposure() {
fn wildcard_belt_advertises_collapsed_tools_not_their_hidden_members() {
let visible = visible_names("tools_agent");
- for collapsed in [
- crate::memory::tools::MEMORY_TOOL_NAME,
- "todo",
- crate::tools::implementations::meta::TOOL_SEARCH_NAME,
- ] {
+ for collapsed in [crate::memory::tools::MEMORY_TOOL_NAME, "todo"] {
assert!(
visible.contains(collapsed),
"wildcard belt must advertise `{collapsed}`; got {visible:?}"
@@ -95,6 +91,51 @@ fn wildcard_belt_advertises_collapsed_tools_not_their_hidden_members() {
);
}
+/// A wildcard belt withholds every `Deferred` registration from the wire and
+/// keeps it reachable: never advertised, always in the deferred set the
+/// harness registers for its `tool_search` bridge, and classified `Allow` by
+/// the policy — a found tool the gate refuses as prompt-hidden is the
+/// unusable find this replaced.
+#[test]
+fn wildcard_belt_defers_stock_tools_but_keeps_them_reachable() {
+ let tmp = tempfile::TempDir::new().unwrap();
+ let config = test_config(&tmp);
+ let definition = crate::agent::harness::AgentDefinitionRegistry::builtins_only()
+ .get("tools_agent")
+ .cloned()
+ .expect("tools_agent built-in definition");
+ let agent =
+ crate::agent::OpenHumanSessionHost::from_config_with_definition(&config, &definition)
+ .expect("build tools agent");
+
+ let deferred = agent.deferred_tool_names_for_test();
+ assert!(
+ deferred.contains("stock_quote"),
+ "stock_quote declares Deferred and must land in the deferred set; got {deferred:?}"
+ );
+ assert!(
+ !agent.visible_tool_names_for_test().contains("stock_quote"),
+ "a deferred tool must not be advertised"
+ );
+ assert!(
+ !agent
+ .visible_tool_specs_arc()
+ .iter()
+ .any(|spec| spec.name == "stock_quote"),
+ "a deferred tool must not be in the prompt's spec list"
+ );
+ assert!(
+ agent.tool_policy_session_for_test().is_allowed("stock_quote"),
+ "a deferred tool must be callable once found"
+ );
+ assert!(
+ !agent
+ .visible_tool_names_for_test()
+ .contains(crate::tools::implementations::meta::TOOL_SEARCH_NAME),
+ "tool_search is the harness's intrinsic bridge, never a registered tool"
+ );
+}
+
/// A hand-written `[tools] named` belt is left exactly as written: exposure is
/// only for the wildcard belt. `flow_memory_agent` names three read-only
/// `memory_*` tools; swapping them for `memory` would hand it `store`/`forget`.
diff --git a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
index a82afe2cba..71158fce21 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
@@ -123,6 +123,11 @@ impl OpenHumanSessionHost {
&self.visible_tool_names
}
+ #[cfg(test)]
+ pub(crate) fn deferred_tool_names_for_test(&self) -> &std::collections::HashSet<String> {
+ &self.deferred_tool_names
+ }
+
#[cfg(test)]
pub(crate) fn subagent_tool_ceiling_names_for_test(
&self,