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(session_host): allow host-only sessions to accept untrusted input
Steven Enamakel4975b0f74b01
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_build.rsindex f03f331fb6..86b8541323 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs@@ -480,6 +480,8 @@ impl SessionHostBuilder {runtime_config,hosted_base,definition: None,+ host_only: false,+ untrusted_input: false,omit_memory_context: self.omit_memory_context.unwrap_or(false),payload_summarizer: self.payload_summarizer,tokenjuice_compression: self.tokenjuice_compression,diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_only_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_only_tests.rsindex 0c7328b579..2f439ba7a2 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_only_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_only_tests.rs@@ -181,3 +181,58 @@ async fn the_host_only_policy_still_consults_the_hosts_own_gate() {ToolPolicyDecision::Deny { .. }));}++#[test]+fn only_a_host_only_session_accepts_untrusted_input() {+ let tmp = tempfile::TempDir::new().unwrap();+ let config = test_config(&tmp);+ let mut host_only = crate::agent::OpenHumanSessionHost::from_config_host_only(+ &config,+ &orchestrator_def(),+ Some(&host_belt()),+ None,+ )+ .expect("host-only session");+ let mut normal = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(+ &config,+ &orchestrator_def(),+ &host_belt(),+ None,+ )+ .expect("normal session");++ assert!(host_only.set_untrusted_input(true).is_ok());+ assert!(normal.set_untrusted_input(true).is_err());+ assert!(normal.set_untrusted_input(false).is_ok());+}++/// The registry already keeps every built-in off a host-only belt; this is+/// the layer behind it. The gate the session will enforce at dispatch must+/// refuse a built-in name even if something registered one.+#[tokio::test]+async fn a_host_only_session_enforces_the_deny_by_default_gate() {+ let tmp = tempfile::TempDir::new().unwrap();+ let config = test_config(&tmp);+ let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(+ &config,+ &orchestrator_def(),+ Some(&host_belt()),+ None,+ )+ .expect("host-only session");++ assert_eq!(agent.tool_policy.name(), "host_only");+ assert_eq!(+ agent.tool_policy.check(&request("read_file")).await,+ ToolPolicyDecision::Allow+ );+ for built_in in ["shell", "write_file", "spawn_subagent", "tool_search"] {+ assert!(+ matches!(+ agent.tool_policy.check(&request(built_in)).await,+ ToolPolicyDecision::Deny { .. }+ ),+ "{built_in} must be refused by the session's gate"+ );+ }+}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 bfd30de7e6..efbd921fc5 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@@ -130,13 +130,34 @@ impl OpenHumanSessionHost {session_id: Option<&str>,) -> Result<Self> {let definition = host_only_definition(definition);- OpenHumanSessionHost::build_session_agent_inner(+ let mut agent = OpenHumanSessionHost::build_session_agent_inner(config,&definition.id,Some(&definition),true,host,session_id,- )+ )?;+ agent.host_only = true;+ Ok(agent)+ }++ /// Treat the messages this session runs as untrusted data: skip the+ /// prompt-injection guard in [`Self::run_single`].+ ///+ /// A reviewer has to read a PR diff that says "ignore previous+ /// instructions"; the guard would refuse it. Only a host-only session+ /// may, because it has nothing it could be talked into doing.+ ///+ /// # Errors+ ///+ /// When `untrusted` is set on a session not built host-only.+ pub fn set_untrusted_input(&mut self, untrusted: bool) -> Result<()> {+ anyhow::ensure!(+ !untrusted || self.host_only,+ "untrusted input is only allowed on a host-only session"+ );+ self.untrusted_input = untrusted;+ Ok(())}}diff --git a/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs b/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rsindex 1159ae4536..7108e99bbc 100644--- a/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs@@ -41,7 +41,9 @@ impl OpenHumanSessionHost {session_id: Some(self.event_session_id()),},);- if !matches!(guard.action, PromptEnforcementAction::Allow) {+ // A host-only session reading untrusted data has opted out; see+ // `set_untrusted_input`, which refuses any other session.+ if !self.untrusted_input && !matches!(guard.action, PromptEnforcementAction::Allow) {let user_message = match guard.action {PromptEnforcementAction::Allow => "Message accepted.",PromptEnforcementAction::Blocked => "Prompt blocked by security policy.",diff --git a/crates/openhuman-core/src/agent/session_host/types.rs b/crates/openhuman-core/src/agent/session_host/types.rsindex 0d2df0f3fe..2634f09359 100644--- a/crates/openhuman-core/src/agent/session_host/types.rs+++ b/crates/openhuman-core/src/agent/session_host/types.rs@@ -409,6 +409,12 @@ pub struct OpenHumanSessionHost {/// keeps those settings instead of having them silently replaced by/// whatever the process-global registry holds under the same id.pub(super) definition: Option<Arc<crate::agent::harness::definition::AgentDefinition>>,+ /// Built by `from_config_host_only`: the belt is the host's tools alone.+ pub(super) host_only: bool,+ /// The next messages are untrusted data, so `run_single` skips the+ /// prompt guard. Only ever set on a `host_only` session; see+ /// [`OpenHumanSessionHost::set_untrusted_input`].+ pub(super) untrusted_input: bool,/// Mirrors the agent definition's `omit_memory_context` flag: when set,/// a new session does not get the compiled `context.md` prepended to its/// first user message. Defaults to `false` (inject) for agents builtdiff --git a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rsindex f2dc1a8f23..3e19425a64 100644--- a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs+++ b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs@@ -391,6 +391,13 @@ pub async fn agent_chat_reply_for(agent.set_thread_id(Some(id));log::debug!("[inference] agent_chat bound session for thread_id={id}");}+ if let AgentChatTarget::Definition {+ untrusted_input: true,+ ..+ } = target+ {+ agent.set_untrusted_input(true).map_err(|e| e.to_string())?;+ }// A seeded turn replaces resume rather than adding to it.//// The three calls are one operation and the order is load-bearing: