Skip to content

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

fix(session_host): include synthesized tools in deferred tool name computation

Steven Enamakel36c0b1065daf
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 13db28fcc3..e6ef53a9e7 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
@@ -94,13 +94,17 @@ 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 deferred_names = if belt_is_wildcard {
- crate::tools::implementations::meta::strip_deferred_from_visible(
- &mut visible_names,
- tools.as_slice(),
- )
- } else if discovery_opted_in {
- let deferred = crate::tools::implementations::meta::deferred_tool_names(tools.as_slice());
+ let discovery_enabled = belt_is_wildcard || discovery_opted_in;
+ let deferred_names = if discovery_enabled {
+ // Durable AND synthesised: a per-action integration tool is
+ // synthesised per session (`collect_orchestrator_tools`) and
+ // declares `Deferred` too. The synthesised set's `Hidden` members
+ // are left alone on purpose — see the comment above.
+ let mut deferred =
+ crate::tools::implementations::meta::deferred_tool_names(tools.as_slice());
+ deferred.extend(crate::tools::implementations::meta::deferred_tool_names(
+ synthesized_tools.as_slice(),
+ ));
visible_names.retain(|name| !deferred.contains(name));
deferred
} else {
@@ -300,6 +304,7 @@ impl SessionHostBuilder {
visible_tool_specs: Arc::new(visible_tool_specs),
visible_tool_names: visible_names,
deferred_tool_names: deferred_names,
+ discovery_enabled,
subagent_tool_ceiling_names,
tool_policy_session,
memory,
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 9ed2d853b0..602285fd79 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
@@ -638,8 +638,14 @@ impl OpenHumanSessionHost {
// The tool stays in `synthed`, so it stays registered
// and dispatchable for a replayed transcript or a saved
// skill that names it — exactly like a packed tool.
+ //
+ // A synthesised `Deferred` tool (a per-action
+ // integration tool) is likewise not advertised: it is
+ // reachable through `tool_search` when the belt opts
+ // in, and the session builder keeps it in the deferred
+ // set beside the visible one.
for t in &synthed {
- if t.exposure() == tinytools::ToolExposure::Hidden {
+ if t.exposure() != tinytools::ToolExposure::Direct {
continue;
}
set.insert(t.name().to_string());
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 3e5ba33344..59531004a3 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
@@ -441,10 +441,32 @@ impl OpenHumanSessionHost {
&mut self.visible_tool_names,
&self.agent_definition_name,
);
- self.deferred_tool_names = crate::tools::implementations::meta::strip_deferred_from_visible(
+ // Durable `Hidden` members leave the wire here; the deferred split
+ // over both sets is the shared recompute below.
+ let _ = crate::tools::implementations::meta::strip_deferred_from_visible(
&mut self.visible_tool_names,
self.tools.as_slice(),
);
+ self.recompute_deferred_tool_names();
+ }
+
+ /// Re-derive [`Self::deferred_tool_names`] from the current durable and
+ /// synthesised sets and take those names off the advertised set. Called
+ /// wherever either set changes; a no-op for a belt that never opted into
+ /// discovery.
+ pub(in crate::agent::session_host) fn recompute_deferred_tool_names(&mut self) {
+ if !self.discovery_enabled {
+ self.deferred_tool_names.clear();
+ return;
+ }
+ let mut deferred =
+ crate::tools::implementations::meta::deferred_tool_names(self.tools.as_slice());
+ deferred.extend(crate::tools::implementations::meta::deferred_tool_names(
+ self.synthesized_tools.as_slice(),
+ ));
+ self.visible_tool_names
+ .retain(|name| !deferred.contains(name));
+ self.deferred_tool_names = deferred;
}
/// The names the harness registers for a turn: the advertised set plus
diff --git a/crates/openhuman-core/src/agent/session_host/turn/tools.rs b/crates/openhuman-core/src/agent/session_host/turn/tools.rs
index 99a359f40a..9c78c61065 100644
--- a/crates/openhuman-core/src/agent/session_host/turn/tools.rs
+++ b/crates/openhuman-core/src/agent/session_host/turn/tools.rs
@@ -646,6 +646,10 @@ impl OpenHumanSessionHost {
&agent_id,
);
}
+ // The synthesis above can carry `Deferred` entries (per-action
+ // integration tools for a newly connected toolkit); keep them off the
+ // wire and in the searchable set, exactly as the build did.
+ self.recompute_deferred_tool_names();
// Rebuild the visible-spec cache from the new tool_specs so the
// next provider call carries the reconciled schema. Dedup
diff --git a/crates/openhuman-core/src/agent/session_host/types.rs b/crates/openhuman-core/src/agent/session_host/types.rs
index 8c759d2d6d..d0dd85dcea 100644
--- a/crates/openhuman-core/src/agent/session_host/types.rs
+++ b/crates/openhuman-core/src/agent/session_host/types.rs
@@ -159,6 +159,11 @@ pub struct OpenHumanSessionHost {
/// policy session exactly like a visible tool — a found tool the gate
/// refused as "prompt-hidden" would be the old unusable find again.
pub(super) deferred_tool_names: std::collections::HashSet<String>,
+ /// Whether this belt reaches deferred tools at all: a wildcard belt
+ /// always does, a `[tools] named` belt only by listing `tool_search`.
+ /// Fixed at build; the refresh paths use it to recompute
+ /// [`Self::deferred_tool_names`] when the synthesised set changes.
+ pub(super) discovery_enabled: bool,
/// Explicit profile/channel ceiling inherited by delegated agents.
///
/// This is deliberately separate from [`Self::visible_tool_names`]: a