Skip to content

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

feat(session-host): add permanent tool names to host tool merging

Steven Enamakel718ce36158c2
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 631cb47174..08117159d0 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
@@ -777,14 +777,17 @@ 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, withheld_tool_names) =
- super::host_tools::merge_for_turn(host, agent_id, session_id, &mut tools, &mut visible);
+ let merged_host_tools =
+ super::host_tools::merge_for_turn(host, agent_id, session_id, &mut tools, &mut visible)?;
+ let host_policy = merged_host_tools.policy;
+ let withheld_tool_names = merged_host_tools.withheld;
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)
+ .permanent_tool_names(merged_host_tools.permanent)
.deferred_tools(target_def.map_or_else(Vec::new, |d| d.deferred_tools.clone()))
.tool_dispatcher(tool_dispatcher)
.prompt_builder(prompt_builder)
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index 02f34553bc..96679184a0 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -330,19 +330,19 @@ impl OpenHumanTurnPrelude {
/// semantics, but keeps the mutable authority in hook state rather than a
/// second turn loop. A revoked delegate is removed from the executable
/// source, schema, and policy together before this request is prepared.
- fn refresh_delegation_tool_surface(&self) {
+ fn refresh_delegation_tool_surface(&self) -> anyhow::Result<()> {
use crate::agent::harness::definition::AgentDefinitionRegistry;
use crate::tools::agent_policy::ToolPolicyEngine;
use crate::tools::orchestrator_tools::collect_orchestrator_tools;
let Some(registry) = AgentDefinitionRegistry::global() else {
- return;
+ return Ok(());
};
let Some(definition) = registry.get(&self.agent_definition_id).cloned() else {
- return;
+ return Ok(());
};
if definition.subagents.is_empty() {
- return;
+ return Ok(());
}
let (integrations, integrations_are_authoritative) = {
let mutable = self
@@ -371,6 +371,10 @@ impl OpenHumanTurnPrelude {
integrations_are_authoritative,
);
collected.extend(rebuilt);
+ super::managed_tools::reject_synthesized_collisions(
+ &surface.permanent_tool_names,
+ &collected,
+ )?;
let synthesized =
super::builder::drop_synthesized_name_collisions(&surface.tools, collected);
let synthesized_names = synthesized
@@ -460,6 +464,7 @@ impl OpenHumanTurnPrelude {
surface.synthesized_tools = synthesized_tools;
surface.visible_tool_specs = Arc::new(visible);
surface.tool_policy_session = policy;
+ Ok(())
}
fn drain_host_events(&self) -> bool {