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
Merge remote-tracking branch 'upstream/main' into saas-phase5
Steven Enamakel36aea885456a
diff --cc crates/openhuman-core/src/memory/engine.rsindex 933d6a2fb3,f65688f204..e9c591d3e5--- a/crates/openhuman-core/src/memory/engine.rs+++ b/crates/openhuman-core/src/memory/engine.rs@@@ -176,18 -217,88 +217,93 @@@ pub fn resolve(config: &Config) -> Bind}}if let Some(bound) = host_engine() {- return Binding::On(bound);+ // A host engine is one store for the whole process: in SaaS it would+ // put every user in one engine, so it is ignored there.+ if !crate::core::runtime::is_saas() {+ return Binding::On(bound);+ }+ tracing::warn!("[memory:engine] ignoring the host engine in SaaS mode");}+ let root = if super::scope::layout_is_v3(config) {+ match super::scope::user_root(config) {+ Some(root) => Some(root),+ None => return off(None, None, "sign in to use memory in its own layout"),+ }+ } else {+ None+ };+ resolve_configured(config, root.as_deref())+ }++ /// The engine the layout migration needs, for an explicit layout whatever+ /// `[memory] layout` says: `None` the legacy tree, `Some("org:<id>")` the+ /// person's v3 subtree, with the actor `user:<id>` as its owner. Same endpoint,+ /// credential, headers and scrubbing as [`resolve`]; the two layouts are+ /// cached apart, so both can be held at once.+ ///+ /// # Errors+ ///+ /// Memory is off for `config`, or an embedding host's (or a test's)+ /// installed engine is bound, which has one layout of its own and cannot be+ /// bound below a scope root.+ pub fn bind_with_root(config: &Config, root: Option<&str>) -> MemoryResult<BoundEngine> {+ #[cfg(test)]+ {+ let installed = TEST_ROOT_ENGINES+ .read()+ .unwrap_or_else(std::sync::PoisonError::into_inner)+ .get(&(config.workspace_dir.clone(), root.map(str::to_string)))+ .cloned();+ if let Some(engine) = installed {+ return Ok(BoundEngine {+ id: engine.descriptor().id.to_string(),+ endpoint: "test://engine".to_string(),+ engine: super::guard::ScrubbingEngine::wrap(engine),+ });+ }+ let one_engine = TEST_ENGINES+ .read()+ .unwrap_or_else(std::sync::PoisonError::into_inner)+ .contains_key(&config.workspace_dir);+ if one_engine {+ return match root {+ None => resolve(config).engine(),+ Some(_) => Err(MemoryError::Engine(+ "the installed test engine cannot be bound below a scope root".to_string(),+ )),+ };+ }+ }+ if host_engine().is_some() && root.is_some() {+ return Err(MemoryError::Engine(+ "the host's memory engine cannot be bound below a scope root".to_string(),+ ));+ }+ if root.is_none() {+ if let Some(bound) = host_engine() {+ return Ok(bound);+ }+ }+ resolve_configured(config, root).engine()+ }++ /// The configured engine with its scope root (`None` legacy).+ fn resolve_configured(config: &Config, root: Option<&str>) -> Binding {let engine_id = config.memory.engine.trim().to_string();match engine_id.as_str() {- TINYHUMANS_ENGINE => resolve_tinyhumans(config),- CORTEXDB_ENGINE => resolve_cortexdb(config),- "" => off(None, None, "no memory engine selected"),+ TINYHUMANS_ENGINE => resolve_tinyhumans(config, root),+ CORTEXDB_ENGINE => resolve_cortexdb(config, root),+ "" => {+ let reason = if config.memory.legacy_backend_unsupported+ || config.memory.legacy_backend.is_some()+ {+ "legacy memory backend is unsupported; select an explicit v2 memory engine"+ .to_string()+ } else {+ "no memory engine selected".to_string()+ };+ off(None, None, &reason)+ }other => {tracing::warn!(engine = %other, "[memory:engine] unknown engine id in config");off(diff --cc crates/openhuman-core/src/memory/ops.rsindex 3a359d4f6a,e796b05cc9..89153348bf--- a/crates/openhuman-core/src/memory/ops.rs+++ b/crates/openhuman-core/src/memory/ops.rs@@@ -8,8 -8,8 +8,8 @@@use chrono::Utc;use tinymemory_api::{- FetchRequest, ForgetTarget, ItemId, LearningKind, ListRequest, MemoryMeta, MetaFilter,- RecallRequest, StoreItem, StoreReceipt,+ EraseRequest, FetchRequest, ForgetTarget, ItemId, LearningKind, ListRequest, MemoryMeta,- RecallRequest, StoreItem, StoreReceipt, TimeHint, WriteOptions,++ MetaFilter, RecallRequest, StoreItem, StoreReceipt, TimeHint, WriteOptions,};use crate::config::Config;@@@ -147,9 -158,10 +158,10 @@@ pub async fn recall(config: &Config, palet bound = bound(config)?;let request = RecallRequest {question: params.question,- filter: params.filter.unwrap_or_default(),+ filter: confine_filter(config, params.filter.unwrap_or_default()),limit: clamp_limit(params.limit),instructions: None,+ refers_to: time_hint(config, params.refers_to)?,};request.validate()?;let answer = bound.engine.recall(request).await?;diff --cc crates/openhuman-core/src/web_chat/ops/state.rsindex a830e32fa0,e9cce3b44a..445e96e1b0--- a/crates/openhuman-core/src/web_chat/ops/state.rs+++ b/crates/openhuman-core/src/web_chat/ops/state.rs@@@ -39,23 -39,16 +39,30 @@@ pub(crate) fn key_for(thread_id: &str)scoped_key(agent.as_deref(), thread_id)}+/// `key` with the calling scope's agent prefix removed: the id the caller+/// chose, for handing back to it.+pub(crate) fn unscope(key: &str) -> String {+ let agent = crate::core::runtime::CoreContext::current()+ .and_then(|context| context.session_agent().map(str::to_owned));+ match agent {+ Some(agent) => key- .strip_prefix(&format!("{agent}::"))++ .strip_prefix(&scoped_key(Some(&agent), ""))+ .unwrap_or(key)+ .to_string(),+ None => key.to_string(),+ }+}++ /// Injective encoding of `(session_agent, thread_id)`. Both parts are caller+ /// controlled, so a plain `agent::thread` join would let `("a", "b::c")` and+ /// `("a::b", "c")` (or an unscoped `"a::b"`) share one slot. A scoped key is+ /// `\x1f<agent byte length>:<agent><thread>`; an unscoped key is the bare+ /// thread id, except that an id starting with `\x1f` gets a second `\x1f`+ /// prepended so it can never look like a scoped key.pub(crate) fn scoped_key(session_agent: Option<&str>, thread_id: &str) -> String {match session_agent {- Some(agent) => format!("{agent}::{thread_id}"),+ Some(agent) => format!("\u{1f}{}:{agent}{thread_id}", agent.len()),+ None if thread_id.starts_with('\u{1f}') => format!("\u{1f}{thread_id}"),None => thread_id.to_string(),}}diff --cc scripts/ci/check-openhuman-rust-layout.mjsindex 833519cd1f,d3ca138959..a679ee1b0a--- a/scripts/ci/check-openhuman-rust-layout.mjs+++ b/scripts/ci/check-openhuman-rust-layout.mjs@@@ -43,10 -43,10 +43,10 @@@ const LEGACY_LIMIT_ENTRIES =// provider, security, memory, tool and prompt policy. Generic session// state moved to tinyagents-runtime; this remaining composition is split in// a follow-up without reintroducing an old harness/session exception.- ["crates/openhuman-core/src/agent/session_host/builder/factory.rs", 1001],+ ["crates/openhuman-core/src/agent/session_host/builder/factory.rs", 984],["crates/openhuman-core/src/agent/subagent_host/lifecycle.rs", 1309],["crates/openhuman-core/src/agent/subagent_host/ops/runner.rs", 1152],- ["crates/openhuman-core/src/tools/ops.rs", 1209],+ ["crates/openhuman-core/src/tools/ops.rs", 1208],["crates/openhuman-core/src/web_chat/progress_bridge.rs", 1304],// These established external test modules grew with upstream coverage. Pin// their current sizes while follow-up work separates their test concerns.