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(profiles): admit operator tools named in an agent's scope
Steven Enamakel5477eaf640f8
diff --git a/crates/openhuman-core/src/agent/host_overrides.rs b/crates/openhuman-core/src/agent/host_overrides.rsindex c475dd4b15..d0d9493cff 100644--- a/crates/openhuman-core/src/agent/host_overrides.rs+++ b/crates/openhuman-core/src/agent/host_overrides.rs@@ -29,6 +29,11 @@ pub struct HostOverrides {pub role_models: BTreeMap<String, Arc<dyn ChatModel<()>>>,/// The agent's durable session store, ahead of the runtime's store.pub session_store: Option<Arc<dyn tinyagents_session::port::SessionStoreProvider>>,+ /// The tools the agent's definition names, when its scope is a named+ /// list: what lets an embedded agent have one of the+ /// [`OPERATOR_ADMITTABLE`](crate::profiles::tools::OPERATOR_ADMITTABLE)+ /// tools although its domain family is off.+ pub named_tools: Option<Arc<std::collections::HashSet<String>>>,}impl std::fmt::Debug for HostOverrides {@@ -53,6 +58,14 @@ impl HostOverrides {})}+ /// The named tool scope of this agent, or of the nearest parent that has+ /// one.+ pub fn named_tools(&self) -> Option<Arc<std::collections::HashSet<String>>> {+ self.named_tools+ .clone()+ .or_else(|| self.parent.as_ref().and_then(|parent| parent.named_tools()))+ }+/// Resolve the instance barrier inherited by derived turn contexts.pub fn approval_scope(&self) -> Option<Arc<crate::security::approval::ApprovalScope>> {self.approval_scopediff --git a/crates/openhuman-core/src/profiles/tools.rs b/crates/openhuman-core/src/profiles/tools.rsindex ad25a2e9d3..e11309f48e 100644--- a/crates/openhuman-core/src/profiles/tools.rs+++ b/crates/openhuman-core/src/profiles/tools.rs@@ -109,12 +109,13 @@ pub const HARD_DENIED: &[&str] = &["pushover",];-/// Tools outside a profile's domain families that an operator may still admit-/// by naming them in `tool_scope(ToolScopeSpec::Named(..))`: the scheduler-/// (`cron`, an Automation tool, bounded by `[cron] agent_jobs_only`) and the-/// two clock tools (`current_time`, `resolve_time`, Platform tools with no-/// reach beyond the wall clock). Nothing else in those families qualifies, and-/// a name not in the operator's scope is never registered.+/// Tools outside a profile's (or an embedded agent's) domain families that an+/// operator may still admit by naming them in+/// `tool_scope(ToolScopeSpec::Named(..))`: the scheduler (`cron`, bounded by+/// `[cron] agent_jobs_only`) and the two clock tools (`current_time`,+/// `resolve_time`, Platform tools with no reach beyond the wall clock).+/// Nothing else in those families qualifies, and a name not in the scope is+/// never registered. An embedded agent names them in its definition's scope.pub const OPERATOR_ADMITTABLE: &[&str] = &["cron", "current_time", "resolve_time"];/// Whether `tool` is hard-denied to users.@@ -164,10 +165,11 @@ pub fn allowlisted() -> Vec<SaasToolGroup> {.unwrap_or_default()}-/// The tool-list filter. Outside SaaS this is the domain filter alone.+/// The tool-list filter. Outside SaaS this is the domain filter, plus the+/// [`OPERATOR_ADMITTABLE`] tools the current agent names in its scope.pub fn admits(tool: &str, domain_ok: bool) -> bool {if !is_saas() {- return domain_ok;+ return domain_ok || admitted_by_name(tool, current_named_tools().as_deref());}let mut admitted = admits_with(tool, domain_ok, &allowlisted());if !admitted@@ -184,6 +186,23 @@ pub fn admits(tool: &str, domain_ok: bool) -> bool {admitted}+/// Whether `tool` is one of the [`OPERATOR_ADMITTABLE`] tools and `named`+/// lists it.+pub fn admitted_by_name(tool: &str, named: Option<&std::collections::HashSet<String>>) -> bool {+ let admitted = OPERATOR_ADMITTABLE.contains(&tool) && named.is_some_and(|names| names.contains(tool));+ if admitted {+ log::debug!("[profiles][tools] admitting named `{tool}` outside its domain family");+ }+ admitted+}++/// The named tool scope of the agent the current context serves, if any.+fn current_named_tools() -> Option<std::sync::Arc<std::collections::HashSet<String>>> {+ crate::core::runtime::context::CoreContext::current()?+ .host_overrides()?+ .named_tools()+}+/// The approval gate's answer in SaaS, where it never parks: `Ok` for a tool/// in an allowlisted group, otherwise the refusal.pub fn gate_verdict_with(tool: &str, groups: &[SaasToolGroup]) -> Result<(), String> {diff --git a/crates/openhuman-embed/src/agent/build.rs b/crates/openhuman-embed/src/agent/build.rsindex cfc609e42f..eaf66e5a97 100644--- a/crates/openhuman-embed/src/agent/build.rs+++ b/crates/openhuman-embed/src/agent/build.rs@@ -270,6 +270,9 @@ pub(crate) fn instantiate(runtime: &Runtime, spec: AgentSpec) -> Result<AgentInnoverrides.model = provider.custom_model();overrides.role_models = provider.role_models().clone();overrides.session_store = parts.session_store;+ if let openhuman_core::agent::harness::definition::ToolScope::Named(names) = &definition.tools {+ overrides.named_tools = Some(std::sync::Arc::new(names.iter().cloned().collect()));+ }let overrides = std::sync::Arc::new(overrides);for hook in parts.post_turn_hooks {overrides.post_turn_hook(hook.name(), Some(hook.clone()));