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(embed): complete the host-tools seam — Harness, re-exports, docs
sanil-235d3e92eee27a
diff --git a/crates/openhuman-core/src/tools/mod.rs b/crates/openhuman-core/src/tools/mod.rsindex 1db580a200..649734da3e 100644--- a/crates/openhuman-core/src/tools/mod.rs+++ b/crates/openhuman-core/src/tools/mod.rs@@ -67,5 +67,8 @@ pub use schemas::{all_controller_schemas as all_tools_controller_schemas,all_registered_controllers as all_tools_registered_controllers,};-pub use tinytools::{PermissionLevel, ToolCategory, ToolResult, ToolScope, ToolSpec};+// `Tool` itself rides here too, so an embedder implementing a tool reaches the *vendored* tinytools rather than adding a second path to it.+// A second path is not merely duplicate -- it produces incompatible Rust types,+// and a tool built against it cannot be handed to a session at all.+pub use tinytools::{PermissionLevel, Tool, ToolCategory, ToolResult, ToolScope, ToolSpec};pub(crate) use user_filter::filter_tools_by_user_preference;diff --git a/crates/openhuman-embed/src/agent/spec.rs b/crates/openhuman-embed/src/agent/spec.rsindex 355a261989..29bc433ad3 100644--- a/crates/openhuman-embed/src/agent/spec.rs+++ b/crates/openhuman-embed/src/agent/spec.rs@@ -228,9 +228,9 @@ impl AgentSpec {/// belt only on turns that run on a session of their own.////// ```no_run- /// # use openhuman_embed::AgentSpec;- /// # use openhuman_core::agent::HostTurnTools;- /// # fn belt() -> Vec<Box<dyn tinytools::Tool>> { Vec::new() }+ /// use openhuman_embed::{AgentSpec, HostTurnTools, Tool};+ ///+ /// # fn belt() -> Vec<Box<dyn Tool>> { Vec::new() }/// let spec = AgentSpec::new("reviewer").tools(|| HostTurnTools::advertised(belt()));/// ```#[must_use]@@ -242,6 +242,16 @@ impl AgentSpec {self}+ /// [`Self::tools`] for a caller that already holds the factory.+ ///+ /// `HarnessBuilder` forwards its own `tools` through here rather than+ /// wrapping the factory in a second closure.+ #[must_use]+ pub(crate) fn host_tools(mut self, factory: openhuman_core::agent::HostTools) -> Self {+ self.host_tools = Some(factory);+ self+ }+// ── accessors for the build step ─────────────────────────────────────pub(crate) fn into_parts(self) -> AgentSpecParts {diff --git a/crates/openhuman-embed/src/harness/builder.rs b/crates/openhuman-embed/src/harness/builder.rsindex 193f9fdc5f..ba4b019721 100644--- a/crates/openhuman-embed/src/harness/builder.rs+++ b/crates/openhuman-embed/src/harness/builder.rs@@ -31,6 +31,7 @@ pub struct HarnessBuilder {skills_dir: Option<PathBuf>,#[cfg(feature = "mcp")]mcp_servers: Vec<super::mcp::McpServer>,+ host_tools: Option<openhuman_core::agent::HostTools>,services: Option<ServiceSet>,domains: Option<DomainSet>,tool_groups: Option<openhuman_core::tools::toolpacks::ToolGroups>,@@ -59,6 +60,7 @@ impl HarnessBuilder {skills_dir: None,#[cfg(feature = "mcp")]mcp_servers: Vec::new(),+ host_tools: None,services: None,domains: None,tool_groups: None,@@ -119,6 +121,20 @@ impl HarnessBuilder {self}+ /// The harness agent's own in-process tools, built fresh for every turn.+ ///+ /// [`AgentSpec::tools`](crate::AgentSpec::tools) for the one-agent+ /// shorthand, with the same contract — including that `f` runs per turn+ /// and may return a different belt each time.+ #[must_use]+ pub fn tools(+ mut self,+ f: impl Fn() -> openhuman_core::agent::HostTurnTools + Send + Sync + 'static,+ ) -> Self {+ self.host_tools = Some(std::sync::Arc::new(f));+ self+ }+/// Override which background services run.////// The default is deliberately minimal — see [`Harness`] — because cron,@@ -286,6 +302,9 @@ impl HarnessBuilder {let mut spec = AgentSpec::new(HARNESS_AGENT_ID).provider(self.provider).access(self.access);+ if let Some(host_tools) = self.host_tools {+ spec = spec.host_tools(host_tools);+ }if let Some(dir) = self.action_dir {spec = spec.action_dir(dir);} else if !inherit {diff --git a/crates/openhuman-embed/src/lib.rs b/crates/openhuman-embed/src/lib.rsindex e08ffebc9a..769ad0e25e 100644--- a/crates/openhuman-embed/src/lib.rs+++ b/crates/openhuman-embed/src/lib.rs@@ -67,6 +67,11 @@ pub use openhuman_core::api::{product_identity, set_product_identity, ProductIdepub use openhuman_core::config::Config as RuntimeConfig;pub use openhuman_core::security::TrustedAccess;pub use openhuman_core::tools::toolpacks::{GroupMode, ToolGroups};+// The seam `AgentSpec::tools` needs: the belt types, and `Tool` itself from the+// vendored tinytools. An embedder that took `tinytools` as its own dependency+// would build tools of a different, incompatible type.+pub use openhuman_core::agent::{HostTools, HostTurnTools};+pub use openhuman_core::tools::Tool;pub use openhuman_core::{CoreBuilder, CoreRuntime, DaemonConfig, DomainSet, HostKind, ServiceSet, TokenSource,};diff --git a/gitbooks/developing/architecture/agent-harness.md b/gitbooks/developing/architecture/agent-harness.mdindex d39ecd7a66..f27b56d707 100644--- a/gitbooks/developing/architecture/agent-harness.md+++ b/gitbooks/developing/architecture/agent-harness.md@@ -14,11 +14,38 @@ in-process core per process — background services, registered domainfamilies, backend URL and the TinyHumans API key — and `Runtime::agent(spec)`instantiates any number of agents on it. Each `AgentSpec` fully describesone agent: provider endpoint and model, access tier, `action_dir`, MCP-servers, skill bundles, system prompt, tool scope, sandbox mode, allowlists,-and a narrowed `DomainSet` / `ToolGroups`. A runtime identifies as+servers, its own in-process tools, skill bundles, system prompt, tool scope,+sandbox mode, allowlists, and a narrowed `DomainSet` / `ToolGroups`. A runtime identifies as`HostKind::Library`: inference does not depend on OpenHuman app login,including inference-readiness checks for workflow agent nodes.+### An embedder's own tools++`AgentSpec::tools` takes the host's own `Box<dyn Tool>` objects, which reach+the model as real tools — their own schema on the wire, called by their own+name. Before it existed the only road was `AgentSpec::mcp`, and the model paid+for the indirection: a discovery call to learn what a server offers, and an+`mcp_call_tool` envelope whose inner `arguments` object no provider can+validate or constrain decoding against.++It takes a **factory**, not a belt. `Agent` is `Clone` and `Box<dyn Tool>` is+not, and the session behind a spec is rebuilt from `Config` on every turn, so+nothing holding a `dyn Tool` could survive in between. The closure therefore+runs once per turn — which also means a host whose tools belong to something+shorter-lived than the agent (one episode, one room, one assignment) can+return a different belt each time instead of registering a second agent.++Implement `Tool` through `openhuman_embed::Tool`, not by depending on+`tinytools` directly: a second path to that crate produces incompatible Rust+types, and a tool built against it cannot be handed to a session at all.++One caveat on a varying belt. The prompt's tool catalogue is rendered from the+same belt in the same build, so the two stay consistent on any turn that+composes a prompt — but a **resumed** session reuses its persisted system+messages, so a belt that moves under a long-lived thread is described by the+prompt that thread opened with. Vary a belt only on turns that run on a+session of their own.+Per-agent isolation is a context, not a second core. `Runtime::agent` clonesthe runtime's base `Config`, applies the spec, and derives a child`CoreContext` (`CoreContext::derive_with`) carrying that config, the agent's