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(session): persist runtime session state to the session store
Steven Enamakel66e965362ec3
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rsindex 7e2aa5914c..0832aae3d1 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs@@ -738,9 +738,7 @@ impl OpenHumanTurnPrelude {if !crate::agent::session_import::live::dual_write_enabled(self.config.session_dual_write) {return;}- // The dual write mirrors transcript *files* into the session store; a- // host store that is not file-backed is already the only record, and- // there is no file to read.+ // A host store that is not file-backed is the only record: no file to mirror.if crate::agent::session_store::replaces_files() {return;}@@ -1447,20 +1445,12 @@ impl OpenHumanSessionHost {}self.session_history_locator_memo.get_or_init(|| {- // A host session store owns this agent's transcripts; the- // workspace files are only the fallback when none is installed.- if let Some(stores) =- crate::agent::session_store::for_agent(&self.agent_definition_id)- {- log::debug!(- "[session-store] transcripts via host store agent={}",- self.agent_definition_id- );- return stores.transcripts;- }- Arc::new(tinyagents_session::transcript::FileTranscriptLocator::new(- self.workspace_dir.clone(),- ))+ crate::agent::session_store::transcripts_for(&self.agent_definition_id)+ .unwrap_or_else(|| {+ Arc::new(tinyagents_session::transcript::FileTranscriptLocator::new(+ self.workspace_dir.clone(),+ ))+ })}).clone()}diff --git a/crates/openhuman-core/src/agent/session_store/mod.rs b/crates/openhuman-core/src/agent/session_store/mod.rsindex 7f57b5c2fa..f60aea5904 100644--- a/crates/openhuman-core/src/agent/session_store/mod.rs+++ b/crates/openhuman-core/src/agent/session_store/mod.rs@@ -93,6 +93,17 @@ pub fn for_agent(agent_id: &str) -> Option<AgentStores> {installed().map(|provider| provider.for_agent(agent_id))}+/// `agent_id`'s transcripts from the store in effect, or `None` when the core+/// keeps them as workspace files.+#[must_use]+pub fn transcripts_for(+ agent_id: &str,+) -> Option<Arc<dyn tinyagents_session::transcript::TranscriptLocator>> {+ let stores = for_agent(agent_id)?;+ log::debug!("[session_store] transcripts via the host store agent={agent_id}");+ Some(stores.transcripts)+}+/// The stores of the agent the current [`CoreContext`] works for — the one/// it was derived for ([`CoreContext::session_agent`]), else/// [`DEFAULT_AGENT`] — or `None` when the core keeps the on-disk layout.diff --git a/crates/openhuman-core/src/agent/session_store/mod_tests.rs b/crates/openhuman-core/src/agent/session_store/mod_tests.rsindex cf27d13965..e5c2db0506 100644--- a/crates/openhuman-core/src/agent/session_store/mod_tests.rs+++ b/crates/openhuman-core/src/agent/session_store/mod_tests.rs@@ -41,3 +41,15 @@ async fn only_a_store_without_files_replaces_them() {let memory: Arc<dyn SessionStoreProvider> = Arc::new(InMemorySessionStores::new());assert!(scope(memory, async { replaces_files() }).await);}++#[tokio::test]+async fn transcripts_come_from_the_store_only_when_one_is_in_effect() {+ assert!(transcripts_for("u1").is_none());+ let provider: Arc<dyn SessionStoreProvider> = Arc::new(InMemorySessionStores::new());+ let expected = provider.for_agent("u1").transcripts.destination_key();+ let found = scope(provider, async {+ transcripts_for("u1").map(|locator| locator.destination_key())+ })+ .await;+ assert_eq!(found, Some(expected));+}