Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(memory): scope host engine and filters to the tenant in SaaS

Steven Enamakeld96445517083
diff --git a/crates/openhuman-core/src/memory/engine.rs b/crates/openhuman-core/src/memory/engine.rs
index e9369fddf3..933d6a2fb3 100644
--- a/crates/openhuman-core/src/memory/engine.rs
+++ b/crates/openhuman-core/src/memory/engine.rs
@@ -176,7 +176,12 @@ pub fn resolve(config: &Config) -> Binding {
}
}
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 engine_id = config.memory.engine.trim().to_string();
match engine_id.as_str() {
diff --git a/crates/openhuman-core/src/memory/explore.rs b/crates/openhuman-core/src/memory/explore.rs
index 3a142a8304..91d3f5e95c 100644
--- a/crates/openhuman-core/src/memory/explore.rs
+++ b/crates/openhuman-core/src/memory/explore.rs
@@ -94,7 +94,7 @@ pub fn narrowed(filter: Option<MetaFilter>, path: &[PathStep]) -> MemoryResult<M
pub async fn explore(config: &Config, params: ExploreParams) -> MemoryResult<ExplorePage> {
let bound = engine::resolve(config).engine()?;
let mut request = ExploreRequest::new(params.facet, params.limit.unwrap_or(DEFAULT_BUCKETS));
- request.filter = narrowed(params.filter, &params.path)?;
+ request.filter = super::ops::confine_filter(config, narrowed(params.filter, &params.path)?);
if let Some(scan_limit) = params.scan_limit {
request.scan_limit = scan_limit;
}
diff --git a/crates/openhuman-core/src/memory/ops.rs b/crates/openhuman-core/src/memory/ops.rs
index 239acd7b00..296476e1a1 100644
--- a/crates/openhuman-core/src/memory/ops.rs
+++ b/crates/openhuman-core/src/memory/ops.rs
@@ -183,7 +183,7 @@ pub async fn fetch(config: &Config, params: FetchParams) -> MemoryResult<FetchVi
let request = FetchRequest {
query: params.query,
mode,
- filter: params.filter.unwrap_or_default(),
+ filter: confine_filter(config, params.filter.unwrap_or_default()),
limit: clamp_limit(params.limit),
cursor: params.cursor,
beliefs: 0,