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
feat(agent): persist agent sessions to a store
Steven Enamakelb6f4fb34ef79
diff --git a/crates/openhuman-core/src/agent/mod.rs b/crates/openhuman-core/src/agent/mod.rsindex a708a092a9..b535d90603 100644--- a/crates/openhuman-core/src/agent/mod.rs+++ b/crates/openhuman-core/src/agent/mod.rs@@ -66,6 +66,7 @@ pub mod session_db;/// snapshots are owned by `tinyagents-runtime`.pub mod session_host;pub mod session_import;+pub mod session_store;pub mod stop_hooks;/// Product-specific adapters around `tinyagents_orchestration::subagent`./// Generic lifecycle ordering and task-key coalescing live in TinyAgents;diff --git a/crates/openhuman-core/src/agent/session_store/mod.rs b/crates/openhuman-core/src/agent/session_store/mod.rsnew file mode 100644index 0000000000..a6185ac152--- /dev/null+++ b/crates/openhuman-core/src/agent/session_store/mod.rs@@ -0,0 +1,79 @@+//! The host-installed session store.+//!+//! A host that keeps conversations in its own database (a cloud deployment+//! serving many users from one process) installs a+//! [`SessionStoreProvider`] here once, before agents run. From then on every+//! agent's transcripts, turn journal, run status, goals and todos go through+//! that agent's [`AgentStores`] instead of files under `workspace_dir`, and+//! the file-era mirrors (the session dual-write and its shadow reads) stand+//! down: the host store is the only record.+//!+//! Like the memory engine's host binding+//! ([`crate::memory::engine::install_host_engine`]), this is process-wide:+//! OpenHuman runs one runtime per process. With nothing installed, the core+//! keeps today's on-disk layout.++use std::sync::{Arc, LazyLock, PoisonError, RwLock};++pub use tinyagents_session::port::{AgentStores, SessionStoreProvider};++static PROVIDER: LazyLock<RwLock<Option<Arc<dyn SessionStoreProvider>>>> =+ LazyLock::new(|| RwLock::new(None));++/// Routes every agent's session state through `provider`, replacing any+/// earlier one.+pub fn install(provider: Arc<dyn SessionStoreProvider>) {+ tracing::info!(+ destination = ?provider.destination_key(),+ "[session_store] host session store installed"+ );+ *PROVIDER.write().unwrap_or_else(PoisonError::into_inner) = Some(provider);+}++/// Removes the installed provider; the on-disk layout applies again. Returns+/// whether one was installed.+pub fn clear() -> bool {+ let had = PROVIDER+ .write()+ .unwrap_or_else(PoisonError::into_inner)+ .take()+ .is_some();+ if had {+ tracing::info!("[session_store] host session store removed");+ }+ had+}++/// The installed provider, if any.+#[must_use]+pub fn installed() -> Option<Arc<dyn SessionStoreProvider>> {+ PROVIDER+ .read()+ .unwrap_or_else(PoisonError::into_inner)+ .clone()+}++/// Whether a host session store is installed.+#[must_use]+pub fn is_installed() -> bool {+ PROVIDER+ .read()+ .unwrap_or_else(PoisonError::into_inner)+ .is_some()+}++/// `agent_id`'s stores from the installed provider, or `None` when the core+/// keeps the on-disk layout.+#[must_use]+pub fn for_agent(agent_id: &str) -> Option<AgentStores> {+ installed().map(|provider| provider.for_agent(agent_id))+}++/// The agent whose stores a turn without a definition id uses. Root turns of+/// the desktop app have no per-user agent; a single shared bucket keeps them+/// together, as the shared workspace always did.+pub const DEFAULT_AGENT: &str = "default";++#[cfg(test)]+#[path = "mod_tests.rs"]+mod tests;