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
refactor(session_host): split builder into host-only and host-tools modules
Steven Enamakel5379bb9c963f
diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rsindex 322ad20ddf..2c5c2040e8 100644--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs@@ -224,19 +224,6 @@ impl OpenHumanSessionHost {crate::tools::filter_tools_by_user_preference(&mut tools, &enabled_tools);}- if belt == SessionBelt::ConfigReadOnly {- let before = tools.len();- tools.retain(|tool| {- tool.permission_level() <= PermissionLevel::ReadOnly- && !matches!(tool.scope(), tinytools::ToolScope::CliRpcOnly)- });- log::info!(- "[agent::builder] read-only tool filter applied: before={} after={}",- before,- tools.len()- );- }-// Route the main agent's chat through the unified per-workload// factory so the user's "Reasoning" routing in the AI settings// panel (e.g. `reasoning_provider = "anthropic:claude-..."`)@@ -445,14 +432,8 @@ impl OpenHumanSessionHost {target_def,crate::agent::harness::definition::AgentDefinitionRegistry::global(),) {- // Host-only: no delegation, and an empty named belt the host's- // names are merged into below.- _ if host_only => (- Vec::new(),- Some(std::collections::HashSet::from([- NO_TOOLS_SENTINEL.to_string()- ])),- ),+ // Host-only: no delegation; the host's names join an empty belt.+ _ if host_only => (Vec::new(), Some(super::host_only::empty_belt())),(Some(def), Some(reg)) => {let synthed = if should_synthesize_delegation_tools(def) {tools::orchestrator_tools::collect_orchestrator_tools(@@ -607,7 +588,6 @@ impl OpenHumanSessionHost {// below so an agent that explicitly disallows it still has it removed.// A summary names the tool in its footer too, and summaries run with// the router off, so either one makes the tool necessary.- // Not on a host-only belt: the recovery tool is not the host's.if !host_only {super::ensure_tinyjuice_tools_visible(&mut visible, agent_id, config);}@@ -798,18 +778,8 @@ impl OpenHumanSessionHost {&mut visible,)?;let session_definition = super::host_tools::scope_def(target_def, &merged_host_tools);- // Host-only: the host's names, and only those, are admitted; the- // host's own gate (if any) still decides among them.- let host_policy = if host_only {- let allowed = tools.iter().map(|tool| tool.name().to_string()).collect();- Some(Arc::new(super::host_only::HostOnlyToolPolicy::new(- allowed,- merged_host_tools.policy,- ))- as Arc<dyn crate::agent::tool_policy::ToolPolicy>)- } else {- merged_host_tools.policy- };+ let host_policy =+ super::host_only::session_policy(host_only, &tools, 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))diff --git a/crates/openhuman-core/src/agent/session_host/builder/host_only.rs b/crates/openhuman-core/src/agent/session_host/builder/host_only.rsindex cbc5ecbcee..bfd30de7e6 100644--- a/crates/openhuman-core/src/agent/session_host/builder/host_only.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/host_only.rs@@ -72,6 +72,28 @@ impl ToolPolicy for HostOnlyToolPolicy {}}+/// The visible set of a host-only belt before the host's names are merged in:+/// explicitly zero tools (an empty set would mean "no filter").+pub(super) fn empty_belt() -> HashSet<String> {+ HashSet::from([crate::agent::harness::definition::NO_TOOLS_SENTINEL.to_string()])+}++/// The session gate: on a host-only belt, [`HostOnlyToolPolicy`] over the+/// belt's names (`tools` holds only the host's by then) wrapping the host's+/// own gate; otherwise the host's gate unchanged. The recovery tool and every+/// other config-side addition are kept off the belt by the caller.+pub(super) fn session_policy(+ host_only: bool,+ tools: &[Box<dyn tinytools::Tool>],+ host: Option<Arc<dyn ToolPolicy>>,+) -> Option<Arc<dyn ToolPolicy>> {+ if !host_only {+ return host;+ }+ let allowed = tools.iter().map(|tool| tool.name().to_string()).collect();+ Some(Arc::new(HostOnlyToolPolicy::new(allowed, host)))+}+/// The definition a host-only session runs under: `definition` with every/// route to a tool the host did not supply removed.pub(super) fn host_only_definition(definition: &AgentDefinition) -> AgentDefinition {@@ -112,7 +134,7 @@ impl OpenHumanSessionHost {config,&definition.id,Some(&definition),- super::factory::SessionBelt::HostOnly,+ true,host,session_id,)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 948c42d712..ff7df5351a 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@@ -355,7 +355,7 @@ impl OpenHumanSessionHost {config,&definition.id,Some(definition),- super::factory::SessionBelt::Config,+ false,Some(host),session_id,)