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/core/runtime/saas.rs,crates/openhuman-core/src/user_a
Steven Enamakele809f05a6984
diff --git a/crates/openhuman-core/src/core/runtime/saas.rs b/crates/openhuman-core/src/core/runtime/saas.rsindex 144859b406..4245bc4f38 100644--- a/crates/openhuman-core/src/core/runtime/saas.rs+++ b/crates/openhuman-core/src/core/runtime/saas.rs@@ -211,10 +211,12 @@ pub async fn build(builder = builder.port(port);}let runtime = builder.build().await?;- crate::user_agents::host::install(Arc::new(crate::user_agents::AgentHost::new(+ let host = Arc::new(crate::user_agents::AgentHost::new(config,runtime.context().clone(),- )));+ ));+ crate::user_agents::host::install(Arc::clone(&host));+ crate::user_agents::background::spawn(host);Ok(runtime)}diff --git a/crates/openhuman-core/src/user_agents/host.rs b/crates/openhuman-core/src/user_agents/host.rsindex f175a7e013..81c90307e1 100644--- a/crates/openhuman-core/src/user_agents/host.rs+++ b/crates/openhuman-core/src/user_agents/host.rs@@ -53,6 +53,11 @@ pub struct AgentHost {saas: SaasConfig,operator: Arc<CoreContext>,open: Mutex<HashMap<UserAgentId, Slot>>,+ /// Agents whose leftovers from a previous process were already swept+ /// (see [`recover_workspace`]). Kept across evictions: a re-open after an+ /// eviction must not mark a turn this process is still running as+ /// interrupted.+ recovered: Mutex<std::collections::HashSet<UserAgentId>>,}impl std::fmt::Debug for AgentHost {@@ -81,6 +86,7 @@ impl AgentHost {saas,operator,open: Mutex::new(HashMap::new()),+ recovered: Mutex::new(std::collections::HashSet::new()),}}@@ -89,6 +95,11 @@ impl AgentHost {&self.saas}+ /// Where agent `id`'s state lives, provisioned or not.+ pub fn layout_of(&self, id: &UserAgentId) -> UserAgentLayout {+ self.layout(id)+ }+fn layout(&self, id: &UserAgentId) -> UserAgentLayout {UserAgentLayout::new(&self.saas.root, id)}@@ -160,6 +171,14 @@ impl AgentHost {));}+ let first_open = self+ .recovered+ .lock()+ .unwrap_or_else(PoisonError::into_inner)+ .insert(id.clone());+ if first_open {+ recover_workspace(id, &layout.workspace_dir);+ }let config = layout::agent_config(&layout, id);let context = self.operator.derive_with(ContextOverlay::new(config.clone(), user_domains(), ToolGroups::none())@@ -273,6 +292,27 @@ impl AgentHost {}}+/// Settle what a previous process left in agent `id`'s workspace: turns that+/// were mid-flight become interrupted and run-ledger rows left running are+/// closed. The sweep a single-user core runs at boot, run per agent on its+/// first open in this process. Failures are logged; the agent still opens.+pub(crate) fn recover_workspace(id: &UserAgentId, workspace_dir: &std::path::Path) {+ let now = chrono::Utc::now().to_rfc3339();+ match tinyagents_session::turn_state::store::mark_all_interrupted(+ workspace_dir.to_path_buf(),+ &now,+ ) {+ Ok(0) => {}+ Ok(turns) => log::info!("[user_agents] agent={id} recovered {turns} interrupted turn(s)"),+ Err(error) => log::warn!("[user_agents] agent={id} turn recovery failed: {error}"),+ }+ match tinyagents_session::run_ledger::interrupt_orphaned_agent_runs(workspace_dir) {+ Ok(0) => {}+ Ok(runs) => log::info!("[user_agents] agent={id} settled {runs} orphaned run(s)"),+ Err(error) => log::warn!("[user_agents] agent={id} run recovery failed: {error:#}"),+ }+}+static HOST: OnceLock<Arc<AgentHost>> = OnceLock::new();/// Install the process's agent host. A SaaS boot does this once; later callsdiff --git a/crates/openhuman-core/src/user_agents/mod.rs b/crates/openhuman-core/src/user_agents/mod.rsindex 9b4262f989..bf0608eb25 100644--- a/crates/openhuman-core/src/user_agents/mod.rs+++ b/crates/openhuman-core/src/user_agents/mod.rs@@ -14,6 +14,7 @@//!//! [`CoreContext`]: crate::core::runtime::CoreContext+pub mod background;pub mod credentials;pub mod gateway;pub mod host;