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
fix(session_store): disable dual-write when a host store replaces files
Steven Enamakelc03ae0738785
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rsindex 0832aae3d1..686c0a0343 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs@@ -738,10 +738,6 @@ impl OpenHumanTurnPrelude {if !crate::agent::session_import::live::dual_write_enabled(self.config.session_dual_write) {return;}- // A host store that is not file-backed is the only record: no file to mirror.- if crate::agent::session_store::replaces_files() {- return;- }let Some(stem) = path.file_stem().and_then(|stem| stem.to_str())@@ -1445,12 +1441,10 @@ impl OpenHumanSessionHost {}self.session_history_locator_memo.get_or_init(|| {- crate::agent::session_store::transcripts_for(&self.agent_definition_id)- .unwrap_or_else(|| {- Arc::new(tinyagents_session::transcript::FileTranscriptLocator::new(- self.workspace_dir.clone(),- ))- })+ crate::agent::session_store::transcripts_or_files(+ &self.agent_definition_id,+ &self.workspace_dir,+ )}).clone()}diff --git a/crates/openhuman-core/src/agent/session_import/live.rs b/crates/openhuman-core/src/agent/session_import/live.rsindex 07559f6ffd..36827b249f 100644--- a/crates/openhuman-core/src/agent/session_import/live.rs+++ b/crates/openhuman-core/src/agent/session_import/live.rs@@ -66,11 +66,16 @@ pub const TINYAGENTS_SESSION_KV_STORE: &str = "openhuman_sessions";/// config reload / env change is honored on the next turn. This keeps a clean/// 04.2 seam (reads can flip independently) while making the mirror the default/// so new turns land in the store without opt-in.+///+/// Always off under a host session store that is not file-backed+/// ([`crate::agent::session_store::replaces_files`]): it is already the only+/// record, and there are no transcript files to mirror.pub fn dual_write_enabled(config_enabled: bool) -> bool {let killed = kill_switch_engaged();- let enabled = config_enabled && !killed;+ let replaced = crate::agent::session_store::replaces_files();+ let enabled = config_enabled && !killed && !replaced;log::debug!(- "[session-store] dual-write decision config_enabled={config_enabled} kill_switch={killed} enabled={enabled}"+ "[session-store] dual-write decision config_enabled={config_enabled} kill_switch={killed} host_store={replaced} enabled={enabled}");enabled}diff --git a/crates/openhuman-core/src/agent/session_store/mod.rs b/crates/openhuman-core/src/agent/session_store/mod.rsindex f60aea5904..440895347f 100644--- a/crates/openhuman-core/src/agent/session_store/mod.rs+++ b/crates/openhuman-core/src/agent/session_store/mod.rs@@ -104,6 +104,20 @@ pub fn transcripts_for(Some(stores.transcripts)}+/// [`transcripts_for`] `agent_id`, or the transcript files under+/// `workspace_dir` when no store is in effect — the session host's resolution.+#[must_use]+pub fn transcripts_or_files(+ agent_id: &str,+ workspace_dir: &std::path::Path,+) -> Arc<dyn tinyagents_session::transcript::TranscriptLocator> {+ transcripts_for(agent_id).unwrap_or_else(|| {+ Arc::new(tinyagents_session::transcript::FileTranscriptLocator::new(+ workspace_dir,+ ))+ })+}+/// 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 e5c2db0506..cdd72a5374 100644--- a/crates/openhuman-core/src/agent/session_store/mod_tests.rs+++ b/crates/openhuman-core/src/agent/session_store/mod_tests.rs@@ -53,3 +53,19 @@ async fn transcripts_come_from_the_store_only_when_one_is_in_effect() {.await;assert_eq!(found, Some(expected));}++#[tokio::test]+async fn without_a_store_transcripts_are_workspace_files() {+ let dir = std::path::Path::new("/nonexistent-openhuman-workspace");+ assert_eq!(+ transcripts_or_files("u1", dir).destination_key(),+ Some(dir.to_string_lossy().into_owned())+ );+ let provider: Arc<dyn SessionStoreProvider> = Arc::new(InMemorySessionStores::new());+ let expected = provider.for_agent("u1").transcripts.destination_key();+ let found = scope(provider, async {+ transcripts_or_files("u1", dir).destination_key()+ })+ .await;+ assert_eq!(found, expected);+}