Skip to content

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

feat(session_host): add runtime session setters

Steven Enamakel7e57dda7454a
diff --git a/crates/openhuman-core/src/agent/session_host/builder/setters.rs b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
index 1730a74ac4..08f74adce5 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/setters.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
@@ -192,6 +192,17 @@ impl SessionHostBuilder {
self
}
+ /// Substitutes the transcript backing store for the whole turn path: resume
+ /// reads, turn commits and compaction generations go through `locator`
+ /// instead of files under the workspace.
+ pub fn with_session_history_locator(
+ mut self,
+ locator: Arc<dyn tinyagents_session::transcript::TranscriptLocator>,
+ ) -> Self {
+ self.session_history_locator = Some(locator);
+ self
+ }
+
/// Sets the workspace directory for the agent.
pub fn workspace_dir(mut self, workspace_dir: std::path::PathBuf) -> Self {
self.workspace_dir = Some(workspace_dir);
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index e1b7de0eba..565fdf502d 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -738,6 +738,11 @@ 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 is already the only record, and there is no file to read.
+ if crate::agent::session_store::is_installed() {
+ return;
+ }
let Some(stem) = path
.file_stem()
.and_then(|stem| stem.to_str())
@@ -1441,6 +1446,17 @@ 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(),
))