The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(session_host): deduplicate deferred tool specs in turn snapshot
Steven Enamakelb78476f4ac38
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rsindex 93b3f2c1f7..a85397fd7d 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs@@ -52,25 +52,12 @@ impl OpenHumanTurnPrelude {// the deferred tools beside the advertised ones. The harness// still advertises only the `Direct` registrations and reaches// the rest through its `tool_search` bridge.- ToolSnapshot::new(- surface- .visible_tool_specs- .iter()- .chain(- surface- .tool_specs- .iter()- .filter(|spec| surface.deferred_tool_names.contains(&spec.name)),- )- .filter(|spec| {- self.thread_id.is_some()- || !crate::agent::tinyagents::tool_registration::is_thread_goal_tool(- &spec.name,- )- })- .map(|spec| spec.as_ref().clone())- .collect(),- )+ ToolSnapshot::new(granted_tool_specs(+ &surface.visible_tool_specs,+ &surface.tool_specs,+ &surface.deferred_tool_names,+ self.thread_id.is_some(),+ )).map_err(|error| anyhow::anyhow!(error.to_string()))?};let prefix = if cold {@@ -365,3 +352,39 @@ impl OpenHumanTurnPrelude {self.memory_post_turn(receipt);}}++/// The declarations a turn's snapshot grants: the advertised specs, then the+/// deferred ones, name-unique.+///+/// A deferred name can have two registrations -- a host tool spliced in ahead+/// of a config-derived built-in of the same name (`HostTurnTools::merge_into`).+/// The advertised list is already deduplicated, but `tool_specs` is the raw+/// registry, so both would reach `ToolSnapshot::new`, which refuses two+/// different declarations under one name and fails the whole turn. The first+/// occurrence wins, as it does for the advertised list, so the host's tool is+/// the one granted.+fn granted_tool_specs(+ visible: &[Arc<ToolSpec>],+ registered: &[Arc<ToolSpec>],+ deferred: &std::collections::HashSet<String>,+ has_thread: bool,+) -> Vec<ToolSpec> {+ let specs = visible+ .iter()+ .chain(+ registered+ .iter()+ .filter(|spec| deferred.contains(&spec.name)),+ )+ .filter(|spec| {+ has_thread+ || !crate::agent::tinyagents::tool_registration::is_thread_goal_tool(&spec.name)+ })+ .map(|spec| spec.as_ref().clone())+ .collect::<Vec<_>>();+ specs // RED-CHECK+}++#[cfg(test)]+#[path = "prelude_tests.rs"]+mod tests;