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
feat(session_host): add permanent tool support to session builder
Steven Enamakel22d191fbfaf0
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.rsindex 9c115e37c6..2e1a087e16 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@@ -46,10 +46,11 @@ impl SessionHostBuilder {// The synthesised set lives beside the durable registry, never inside// it (`OpenHumanSessionHost::synthesized_tools`); a durable name wins a collision.let synthesized_tools = self.synthesized_tools.unwrap_or_default();- super::super::managed_tools::reject_synthesized_collisions(+ tinyagents_runtime::reject_synthesized_collisions(&self.permanent_tool_names,&synthesized_tools,- )?;+ )+ .map_err(anyhow::Error::msg)?;let synthesized_tools = super::drop_synthesized_name_collisions(&tools, synthesized_tools);let synthesized_tool_names: std::collections::HashSet<String> = synthesized_tools.iter()diff --git a/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs b/crates/openhuman-core/src/agent/session_host/builder/host_tools.rsindex 0dbd878f00..5ea81e9d89 100644--- a/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs@@ -135,7 +135,7 @@ impl HostTurnTools {0..0,self.tools.into_iter().map(|tool| {if permanent.contains(tool.name()) {- Box::new(super::permanent_tool::PermanentTool(tool)) as Box<dyn Tool>+ Box::new(tinyagents_runtime::PermanentTool(tool)) as Box<dyn Tool>} else {tool}diff --git a/crates/openhuman-core/src/agent/session_host/builder/mod.rs b/crates/openhuman-core/src/agent/session_host/builder/mod.rsindex 99821ae728..1f88741409 100644--- a/crates/openhuman-core/src/agent/session_host/builder/mod.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/mod.rs@@ -14,7 +14,6 @@ mod factory;mod host_only;mod host_tools;mod iteration_cap;-mod permanent_tool;mod profile_factory;mod setters;diff --git a/crates/openhuman-core/src/agent/session_host/builder/permanent_tool.rs b/crates/openhuman-core/src/agent/session_host/builder/permanent_tool.rsdeleted file mode 100644index b92cf2c361..0000000000--- a/crates/openhuman-core/src/agent/session_host/builder/permanent_tool.rs+++ /dev/null@@ -1,98 +0,0 @@-//! Preserve a host tool's execution metadata while fixing its direct exposure.-use serde_json::Value;-use std::any::Any;-use tinytools::{- PermissionLevel, Tool, ToolCallOptions, ToolCategory, ToolExposure, ToolInjectedArgument,- ToolPolicy, ToolResult, ToolRunContext, ToolScope, ToolSpec, ToolTimeout,-};-pub(super) struct PermanentTool(pub Box<dyn Tool>);-#[async_trait::async_trait]-impl Tool for PermanentTool {- fn name(&self) -> &str {- self.0.name()- }- fn description(&self) -> &str {- self.0.description()- }- fn parameters_schema(&self) -> Value {- self.0.parameters_schema()- }- fn exposure(&self) -> ToolExposure {- ToolExposure::Direct- }- async fn execute(&self, args: Value) -> anyhow::Result<ToolResult> {- self.0.execute(args).await- }- async fn execute_with_options(- &self,- args: Value,- options: ToolCallOptions,- ) -> anyhow::Result<ToolResult> {- self.0.execute_with_options(args, options).await- }- async fn execute_with_context(- &self,- args: Value,- options: ToolCallOptions,- context: Option<&dyn ToolRunContext>,- ) -> anyhow::Result<ToolResult> {- self.0.execute_with_context(args, options, context).await- }- fn policy(&self) -> ToolPolicy {- self.0.policy()- }- fn injected_arguments(&self) -> Vec<ToolInjectedArgument> {- self.0.injected_arguments()- }- fn supports_markdown(&self) -> bool {- self.0.supports_markdown()- }- fn permission_level(&self) -> PermissionLevel {- self.0.permission_level()- }- fn permission_level_with_args(&self, args: &Value) -> PermissionLevel {- self.0.permission_level_with_args(args)- }- fn scope(&self) -> ToolScope {- self.0.scope()- }- fn category(&self) -> ToolCategory {- self.0.category()- }- fn family(&self) -> Option<&str> {- self.0.family()- }- fn is_concurrency_safe(&self, args: &Value) -> bool {- self.0.is_concurrency_safe(args)- }- fn external_effect(&self) -> bool {- self.0.external_effect()- }- fn external_effect_with_args(&self, args: &Value) -> bool {- self.0.external_effect_with_args(args)- }- fn max_result_size_chars(&self) -> Option<usize> {- self.0.max_result_size_chars()- }- fn timeout_policy(&self, args: &Value) -> ToolTimeout {- self.0.timeout_policy(args)- }- fn host_extension(&self) -> Option<&(dyn Any + Send + Sync)> {- self.0.host_extension()- }- fn host_call_extension(&self, args: &Value) -> Option<Box<dyn Any + Send + Sync>> {- self.0.host_call_extension(args)- }- fn spec(&self) -> ToolSpec {- self.0.spec()- }- fn display_label(&self, args: &Value) -> Option<String> {- self.0.display_label(args)- }- fn display_detail(&self, args: &Value) -> Option<String> {- self.0.display_detail(args)- }- fn return_direct(&self) -> bool {- self.0.return_direct()- }-}diff --git a/crates/openhuman-core/src/agent/session_host/managed_tools.rs b/crates/openhuman-core/src/agent/session_host/managed_tools.rsdeleted file mode 100644index 36425134ee..0000000000--- a/crates/openhuman-core/src/agent/session_host/managed_tools.rs+++ /dev/null@@ -1,64 +0,0 @@-//! Refresh only the attached-tool catalogue; keep the host prefix frozen.-use std::{collections::HashSet, sync::Arc};-use tinyagents_runtime::PrefixSnapshot;-use tinyinference_llm::message::Message;-use tinytools::ToolSpec;-const MARKER: &str = "<openhuman-permanent-tools>\n";-pub(super) fn refresh_prefix(- prefix: &PrefixSnapshot,- specs: &[Arc<ToolSpec>],- names: &HashSet<String>,-) -> Option<PrefixSnapshot> {- if names.is_empty() {- return None;- }- let mut messages: Vec<Message> = prefix- .messages()- .iter()- .filter(|message| !message.text().starts_with(MARKER))- .cloned()- .collect();- let mut entries: Vec<&ToolSpec> = specs- .iter()- .filter(|spec| names.contains(&spec.name))- .map(AsRef::as_ref)- .collect();- entries.sort_by(|a, b| a.name.cmp(&b.name));- let catalogue = entries- .iter()- .map(|spec| {- format!(- "{}: {}\nParameters: {}",- spec.name, spec.description, spec.parameters- )- })- .collect::<Vec<_>>()- .join("\n\n");- messages.push(Message::system(format!(- "{MARKER}{catalogue}\n</openhuman-permanent-tools>"- )));- if messages == prefix.messages() {- None- } else {- // The TinyAgents session freezes the prefix after its first committed- // turn. This host-managed catalogue is the sole permitted refresh; the- // runtime preserves prior conversation and starts a successor transcript- // generation when it changes.- Some(PrefixSnapshot::new(messages).refreshing())- }-}--/// Check before deduplication, preserving the existing synthesized executors-/// and schemas if a new permanent source would shadow them.-pub(super) fn reject_synthesized_collisions(- names: &HashSet<String>,- synthesized: &[Box<dyn tinytools::Tool>],-) -> anyhow::Result<()> {- if let Some(tool) = synthesized.iter().find(|tool| names.contains(tool.name())) {- anyhow::bail!(- "permanent tool name collision with synthesized tool: {}",- tool.name()- );- }- Ok(())-}diff --git a/crates/openhuman-core/src/agent/session_host/mod.rs b/crates/openhuman-core/src/agent/session_host/mod.rsindex 93fab5af17..fcd0c12d8c 100644--- a/crates/openhuman-core/src/agent/session_host/mod.rs+++ b/crates/openhuman-core/src/agent/session_host/mod.rs@@ -42,7 +42,6 @@ mod hooks;// Tool surface for live voice sessions (`voice::live`).#[cfg(feature = "voice")]mod live_tools;-mod managed_tools;mod prefix_snapshot;mod recorded_tools;mod runtime;diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/permanent.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/permanent.rsindex c32030e4d9..be88b5d0cf 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session/permanent.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/permanent.rs@@ -46,10 +46,12 @@ impl OpenHumanTurnPrelude {.tool_surface.lock().unwrap_or_else(std::sync::PoisonError::into_inner);- preparation.prefix = super::super::managed_tools::refresh_prefix(+ preparation.prefix = tinyagents_runtime::refresh_prefix(preparation.prefix.as_ref().unwrap_or(current),&surface.visible_tool_specs,&surface.permanent_tool_names,+ "<openhuman-permanent-tools>\n",+ "</openhuman-permanent-tools>",).or(preparation.prefix.take());}diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rsindex 80c4c98e45..b3379e9ecd 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rs@@ -76,10 +76,11 @@ impl OpenHumanTurnPrelude {)});collected.extend(rebuilt);- super::super::managed_tools::reject_synthesized_collisions(+ tinyagents_runtime::reject_synthesized_collisions(&surface.permanent_tool_names,&collected,- )?;+ )+ .map_err(anyhow::Error::msg)?;let synthesized =super::super::builder::drop_synthesized_name_collisions(&surface.tools, collected);let synthesized_names = synthesized