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(agent): enforce host-only agents as read-only
Steven Enamakelecd5dd8584b0
diff --git a/crates/openhuman-embed/src/agent/build.rs b/crates/openhuman-embed/src/agent/build.rsindex 307fb323c9..71f1370c1c 100644--- a/crates/openhuman-embed/src/agent/build.rs+++ b/crates/openhuman-embed/src/agent/build.rs@@ -12,6 +12,7 @@ use openhuman_core::core::runtime::{ContextOverlay, DomainSet};use openhuman_core::tools::toolpacks::{GroupMode, ToolGroups};use super::{AgentError, AgentInner, AgentLayout, AgentSpec};+use crate::harness::Access;use crate::runtime::Runtime;pub(crate) fn instantiate(runtime: &Runtime, spec: AgentSpec) -> Result<AgentInner, AgentError> {@@ -22,6 +23,25 @@ pub(crate) fn instantiate(runtime: &Runtime, spec: AgentSpec) -> Result<AgentInnreason,})?;+ // A host-only agent must never act, whatever else the spec says, so its+ // exclusions are settled before any of the spec is applied.+ let host_only = parts.definition.is_host_only();+ if host_only {+ #[cfg(feature = "mcp")]+ if !parts.mcp_servers.is_empty() {+ return Err(AgentError::Invalid(+ "a HostOnly agent cannot declare MCP servers; supply its tools as host tools"+ .into(),+ ));+ }+ #[cfg(feature = "skills")]+ if parts.skills_dir.is_some() {+ return Err(AgentError::Invalid(+ "a HostOnly agent cannot install skills".into(),+ ));+ }+ }+let base = runtime.base_config();let root_dir = base.config_path@@ -52,6 +72,12 @@ pub(crate) fn instantiate(runtime: &Runtime, spec: AgentSpec) -> Result<AgentInnfor (path, grant) in parts.trusted {access = access.trust(path, grant);}+ if host_only {+ // Read-only regardless of what was asked: no tier that could park a+ // write for approval, no automation origin, no trusted roots.+ log::debug!("[embed][agent] id={id} is host-only; forcing read-only access");+ access = Access::readonly();+ }access.apply(&mut config);let provider = parts@@ -98,6 +124,11 @@ pub(crate) fn instantiate(runtime: &Runtime, spec: AgentSpec) -> Result<AgentInn// moved `config_path` would silently point this agent at another.config.config_path = base.config_path.clone();}+ if host_only {+ // After the escape hatch, so it cannot loosen either.+ Access::readonly().apply(&mut config);+ config.mcp_client.enabled = false;+ }// Read back now, after `config_fn` (the escape hatch, applied above) has// had its chance to edit `config.action_dir` — the directory created and@@ -189,6 +220,7 @@ pub(crate) fn instantiate(runtime: &Runtime, spec: AgentSpec) -> Result<AgentInnaccess,layout,host_tools: parts.host_tools,+ host_only,})}diff --git a/crates/openhuman-embed/src/agent/definition.rs b/crates/openhuman-embed/src/agent/definition.rsindex 04efdfee28..6e5d611506 100644--- a/crates/openhuman-embed/src/agent/definition.rs+++ b/crates/openhuman-embed/src/agent/definition.rs@@ -149,6 +149,7 @@ impl AgentDefinitionSpec {/// Materialize the core definition for agent `id`.pub(crate) fn into_core(self, id: &str) -> Result<AgentDefinition, AgentError> {+ let host_only = self.is_host_only();let registry = AgentDefinitionRegistry::builtins_only();let mut def = registry.get(ORCHESTRATOR_ID).cloned().ok_or_else(|| {AgentError::Invalid("built-in orchestrator definition is missing".to_string())@@ -158,7 +159,6 @@ impl AgentDefinitionSpec {if let Some(text) = self.when_to_use {def.when_to_use = text;}- let host_only = self.is_host_only();match self.system_prompt {Some(prompt) if self.bare_prompt => {def.system_prompt = PromptSource::Verbatim(prompt);diff --git a/crates/openhuman-embed/src/agent/mod.rs b/crates/openhuman-embed/src/agent/mod.rsindex 2362cdc2ec..dd79db6077 100644--- a/crates/openhuman-embed/src/agent/mod.rs+++ b/crates/openhuman-embed/src/agent/mod.rs@@ -97,6 +97,9 @@ pub(crate) struct AgentInner {/// The agent's own in-process tools, rebuilt per turn. See/// [`AgentSpec::tools`](super::AgentSpec::tools) for why it is a factory.pub(crate) host_tools: Option<openhuman_core::agent::HostTools>,+ /// Built from [`ToolScopeSpec::HostOnly`]: every turn's session is built+ /// from the host tools alone.+ pub(crate) host_only: bool,}/// A handle to one agent on a runtime.diff --git a/crates/openhuman-embed/src/turn.rs b/crates/openhuman-embed/src/turn.rsindex 8b8683c3e8..174a433462 100644--- a/crates/openhuman-embed/src/turn.rs+++ b/crates/openhuman-embed/src/turn.rs@@ -601,6 +601,7 @@ async fn dispatch(host: host.as_ref(),seed: seed.as_deref(),usage: Some(usage),+ host_only: inner.host_only,};agent_chat_for(&mut config,