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
chore: files changed crates/openhuman-core/src/memory/scope.rs,crates/openhuman-core/src/memory/scop
Steven Enamakel4ec561cd0ab6
diff --git a/crates/openhuman-core/src/memory/scope.rs b/crates/openhuman-core/src/memory/scope.rsindex e08a21a4c1..89b3d805ba 100644--- a/crates/openhuman-core/src/memory/scope.rs+++ b/crates/openhuman-core/src/memory/scope.rs@@ -149,6 +149,17 @@ fn team_root(team: &str) -> Namespace {.unwrap_or(Namespace::ROOT)}+/// Checks that `root` names a usable layout root (`team:acme`,+/// `project:q4/team:ops`), as a host binding is set.+///+/// # Errors+///+/// Why it is not one.+pub fn validate_root(root: &str) -> Result<(), String> {+ let root: Namespace = root.trim().parse().map_err(|error: tinymemory_api::Error| error.to_string())?;+ MemoryLayout::new(root).map(|_| ()).map_err(|error| error.to_string())+}+/// A configured root; an invalid one is logged and ignored.fn parse_root(raw: Option<&str>) -> Option<Namespace> {let raw = raw?.trim();diff --git a/crates/openhuman-core/src/memory/scope_tests.rs b/crates/openhuman-core/src/memory/scope_tests.rsindex feaaf338e2..27bd47e720 100644--- a/crates/openhuman-core/src/memory/scope_tests.rs+++ b/crates/openhuman-core/src/memory/scope_tests.rs@@ -100,3 +100,11 @@ async fn within_agent_scopes_a_child_in_the_same_team() {let alone = within_agent("solo", async { current().unwrap() }).await;assert_eq!(alone, MemoryIdentity::agent("solo"));}++#[test]+fn validate_root_accepts_nodes_and_refuses_junk() {+ assert!(validate_root("team:acme").is_ok());+ assert!(validate_root("project:q4/team:ops").is_ok());+ assert!(validate_root("not a namespace").is_err());+ assert!(validate_root("company:acme").is_err());+}diff --git a/crates/openhuman-embed/src/agent/spec.rs b/crates/openhuman-embed/src/agent/spec.rsindex c694d61d19..7c2db70fa3 100644--- a/crates/openhuman-embed/src/agent/spec.rs+++ b/crates/openhuman-embed/src/agent/spec.rs@@ -51,6 +51,49 @@ pub struct AgentSpec {composio: Option<ComposioHostCredential>,config_fn: Option<ConfigEdit>,host_tools: Option<openhuman_core::agent::HostTools>,+ memory: Option<MemoryBinding>,+}++/// Whose memory an agent reads and writes: the memory agent id its turns are+/// logged under, and the layout root (tenant) its memory lives below.+///+/// Without one, an agent's memory agent id is its definition id and its+/// root is the runtime's default — every agent on the runtime shares+/// learnings and the brain, and keeps its own conversations. A coordinating+/// host that reuses OpenHuman agents as, say, employees of a company binds+/// each to its own id (and, per tenant, its own root).+#[derive(Debug, Clone, PartialEq, Eq)]+pub struct MemoryBinding {+ agent_id: String,+ root: Option<String>,+}++impl MemoryBinding {+ /// Memory under `agent_id`, at the runtime's default root.+ pub fn new(agent_id: impl Into<String>) -> Self {+ Self {+ agent_id: agent_id.into(),+ root: None,+ }+ }++ /// The layout root (`team:acme`, `project:q4`): memory below it is+ /// shared by every agent bound there, and invisible to other roots.+ #[must_use]+ pub fn root(mut self, root: impl Into<String>) -> Self {+ self.root = Some(root.into());+ self+ }++ /// The memory agent id.+ pub fn agent_id(&self) -> &str {+ &self.agent_id+ }++ /// The layout root, when one is set.+ pub fn root_namespace(&self) -> Option<&str> {+ self.root.as_deref()+ }}impl AgentSpec {@@ -81,6 +124,7 @@ impl AgentSpec {composio: None,config_fn: None,host_tools: None,+ memory: None,}}@@ -202,6 +246,14 @@ impl AgentSpec {self}+ /// Binds the agent's memory: the memory agent id its turns are logged+ /// under and, optionally, its layout root. See [`MemoryBinding`].+ #[must_use]+ pub fn memory(mut self, binding: MemoryBinding) -> Self {+ self.memory = Some(binding);+ self+ }+/// Arbitrary edits to the agent's config, applied last.////// The escape hatch for the config fields the spec does not model — not@@ -306,6 +358,7 @@ impl AgentSpec {composio: self.composio,config_fn: self.config_fn,host_tools: self.host_tools,+ memory: self.memory,}}}@@ -330,6 +383,7 @@ pub(crate) struct AgentSpecParts {pub(crate) composio: Option<ComposioHostCredential>,pub(crate) config_fn: Option<ConfigEdit>,pub(crate) host_tools: Option<openhuman_core::agent::HostTools>,+ pub(crate) memory: Option<MemoryBinding>,}impl std::fmt::Debug for AgentSpec {@@ -340,6 +394,7 @@ impl std::fmt::Debug for AgentSpec {.field("access", &self.access).field("action_dir", &self.action_dir).field("composio", &self.composio)+ .field("memory", &self.memory).finish_non_exhaustive()}}