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(tinyagents): register tools and plan turns per request
Steven Enamakeld7330bf56875
diff --git a/crates/openhuman-core/src/agent/tinyagents/tool_registration.rs b/crates/openhuman-core/src/agent/tinyagents/tool_registration.rsindex ff76ecfeb3..c1f923ca39 100644--- a/crates/openhuman-core/src/agent/tinyagents/tool_registration.rs+++ b/crates/openhuman-core/src/agent/tinyagents/tool_registration.rs@@ -13,7 +13,7 @@ use tinyagents_harness::tool::{};use tinyagents_registry::{CapabilityRegistry, ComponentKind, RegistryDiagnostic};use tinyagents_runtime::turn_driver::{SharedToolSet, ToolSetBuilder};-use tinyagents_runtime::{plan_registration, project_descriptors, ToolAdmission};+use tinyagents_runtime::{project_descriptors, ToolAdmission};use tinyinference_llm::model::ChatModel;use tinytools::ToolRunContext;@@ -201,7 +201,7 @@ pub(crate) fn host_tool_set_builder(.exec_scope(Arc::new(TurnOriginScope))}-/// Projects the turn's models, admitted tools, graph topologies and visible+/// Projects the turn's models, the `admitted` tools, graph topologies and visible/// agents into a [`CapabilityRegistry`] and returns its health diagnostics.////// The turn path enforces them fail-closed before the first model dispatch, so@@ -212,19 +212,13 @@ pub(crate) fn host_tool_set_builder(pub(crate) fn capability_diagnostics(models: &[(String, Arc<dyn ChatModel<()>>)],tool_sets: &[SharedToolSet],- admission: &ToolAdmission,+ admitted: &[String],) -> Vec<RegistryDiagnostic> {let mut registry: CapabilityRegistry<()> = CapabilityRegistry::new();for (name, model) in models {registry.replace_model(name.as_str(), model.clone());}- let names: Vec<String> = tool_sets- .iter()- .flat_map(|set| set.iter())- .map(|tool| tool.name().to_string())- .collect();- let plan = plan_registration(names, admission);- for name in &plan.admitted {+ for name in admitted {if let Some(adapter) = shared_tool_adapter(tool_sets.to_vec(), name) {registry.replace_tool(Arc::new(adapter));}diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rsindex 978d295440..9837220e46 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs@@ -281,8 +281,6 @@ async fn run_turn_via_tinyagents_body(error_slot,..} = turn_models;- let registry_diagnostics: Arc<std::sync::Mutex<Vec<tinyagents_registry::RegistryDiagnostic>>> =- Arc::default();let planner = OpenHumanTurnPlanner {models: turn_models_for_plan(model,@@ -295,9 +293,7 @@ async fn run_turn_via_tinyagents_body(tool_sets: tool_sets.clone(),allowed: allowed.clone(),has_thread,- is_subagent,session_deferred: Arc::clone(&run_context.deferred_tool_names),- diagnostics: Arc::clone(®istry_diagnostics),};let driver = TurnDriver::<(), OpenHumanRunContext>::new(Arc::new(planner), Arc::new(()));diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_plan.rs b/crates/openhuman-core/src/agent/tinyagents/turn_plan.rsindex d836dda998..0613232d88 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_plan.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_plan.rs@@ -10,7 +10,7 @@//! the prepared harness by [`turn_middleware`](super::turn_middleware).use std::collections::HashSet;-use std::sync::{Arc, Mutex, PoisonError};+use std::sync::Arc;use async_trait::async_trait;use tinyagents_harness::runtime::RunPolicy;@@ -22,9 +22,7 @@ use tinyinference_llm::model::ErrorSlotModel;use crate::agent::tinyagents::host::OpenHumanRunContext;use crate::agent::tinyagents::model::TurnChatModel;use crate::agent::tinyagents::routes;-use crate::agent::tinyagents::tool_registration::{- capability_diagnostics, host_tool_set_builder, turn_admission,-};+use crate::agent::tinyagents::tool_registration::host_tool_set_builder;use crate::agent::tinyagents::turn_policy::run_policy_for_provider;/// The run policy for one turn, and whether it carries a cross-route fallback.@@ -106,11 +104,7 @@ pub(super) struct OpenHumanTurnPlanner {pub(super) tool_sets: Vec<SharedToolSet>,pub(super) allowed: Option<HashSet<String>>,pub(super) has_thread: bool,- pub(super) is_subagent: bool,pub(super) session_deferred: Arc<HashSet<String>>,- /// Receives the capability registry's health diagnostics; the turn path- /// aborts on an error-severity one before the first model dispatch.- pub(super) diagnostics: Arc<Mutex<Vec<RegistryDiagnostic>>>,}#[async_trait]@@ -119,14 +113,6 @@ impl TurnPlanner<(), OpenHumanRunContext> for OpenHumanTurnPlanner {&self,_request: &DriverRequest<OpenHumanRunContext>,) -> Result<TurnPlan<(), OpenHumanRunContext>, RuntimeError> {- let mut admission = turn_admission(&self.tool_sets, &self.allowed, self.has_thread);- admission.is_subagent_run = self.is_subagent;- *self- .diagnostics- .lock()- .unwrap_or_else(PoisonError::into_inner) =- capability_diagnostics(&self.models, &self.tool_sets, &admission);-let mut plan = TurnPlan::new(self.models.clone());plan.policy = self.policy.clone();plan.tools = host_tool_set_builder(@@ -148,7 +134,7 @@ impl TurnPlanner<(), OpenHumanRunContext> for OpenHumanTurnPlanner {/// tools, a dangling alias) aborts the turn instead of silently resolving to an/// unintended component while a provider call is in flight. Warnings are logged.pub(super) fn enforce_registry_diagnostics(- slot: &Mutex<Vec<RegistryDiagnostic>>,+ registry_diagnostics: &[RegistryDiagnostic],) -> anyhow::Result<()> {let registry_diagnostics =std::mem::take(&mut *slot.lock().unwrap_or_else(PoisonError::into_inner));