Skip to content

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

feat(cost): track per-thread cost in thread bus

Steven Enamakelfe05197e92d6
diff --git a/crates/openhuman-core/src/platform/cost/mod.rs b/crates/openhuman-core/src/platform/cost/mod.rs
index 90d70a50fd..534ac6cb19 100644
--- a/crates/openhuman-core/src/platform/cost/mod.rs
+++ b/crates/openhuman-core/src/platform/cost/mod.rs
@@ -12,7 +12,7 @@ pub mod types;
pub use global::{
init_global, rebind_global, record_embedding_usage, record_provider_usage,
- record_provider_usage_scoped, try_global,
+ record_provider_usage_scoped, seed_tenant_tracker, try_global,
};
pub use route::{route_for_model, CostRoute};
pub use schemas::{
diff --git a/crates/openhuman-core/src/threads/store/bus.rs b/crates/openhuman-core/src/threads/store/bus.rs
index f770fc72bd..3bab7a8384 100644
--- a/crates/openhuman-core/src/threads/store/bus.rs
+++ b/crates/openhuman-core/src/threads/store/bus.rs
@@ -48,6 +48,13 @@ const LOG_PREFIX: &str = "[memory:conversations:bus]";
/// This bridges typed channel events onto the workspace-backed JSONL
/// conversation store so non-web channels persist alongside UI threads.
pub fn register_conversation_persistence_subscriber(workspace_dir: PathBuf) {
+ // One subscriber bound to one workspace cannot serve many users: in SaaS
+ // it would write every user's channel conversations into the operator's
+ // workspace. Profiles keep their threads through their own scoped turns.
+ if crate::core::runtime::is_saas() {
+ log::info!("{LOG_PREFIX} conversation persistence subscriber not registered in SaaS mode");
+ return;
+ }
let workspace = CONVERSATION_PERSISTENCE_WORKSPACE
.get_or_init(|| Arc::new(RwLock::new(workspace_dir.clone())));
match workspace.write() {