Skip to content

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

feat(agent): reap idle live sessions

Steven Enamakela31e6f0b3df0
diff --git a/crates/openhuman-core/src/agent/session_import/live.rs b/crates/openhuman-core/src/agent/session_import/live.rs
index d260c53980..6acd4e7a8a 100644
--- a/crates/openhuman-core/src/agent/session_import/live.rs
+++ b/crates/openhuman-core/src/agent/session_import/live.rs
@@ -85,7 +85,14 @@ pub fn dual_write_enabled(config_enabled: bool) -> bool {
/// dual-write use, so a harness-side reader (04.2+) sees identical records. The
/// journal (`JsonlAppendStore`, an `AppendStore` rather than a `Store`) is not
/// registrable on the `StoreRegistry`; the dual-write opens it directly.
+///
+/// With a host session store installed it is the current agent's key-value
+/// store, whatever the dual-write flag says: there are no files to mirror.
pub async fn session_kv_store() -> Option<Arc<dyn Store>> {
+ if let Some(stores) = crate::agent::session_store::current() {
+ log::debug!("[session-store] registering the host session store's kv on RunContext.stores");
+ return Some(stores.kv);
+ }
let cfg = match crate::config::Config::load_or_init().await {
Ok(cfg) => cfg,
Err(err) => {
diff --git a/crates/openhuman-core/src/agent/tinyagents/reaper.rs b/crates/openhuman-core/src/agent/tinyagents/reaper.rs
index 4b9edaa044..928cb9588f 100644
--- a/crates/openhuman-core/src/agent/tinyagents/reaper.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/reaper.rs
@@ -18,6 +18,12 @@ pub(crate) async fn reap_orphaned_runs(workspace: &Path) -> usize {
"[agent] startup run sweep workspace={}",
workspace.display()
);
+ // A host session store repairs its own runs (`SessionStoreProvider::recover`,
+ // run at boot): its status records are per agent, not in this workspace.
+ if crate::agent::session_store::is_installed() {
+ log::debug!("[agent] startup run sweep skipped: the host session store recovers its runs");
+ return 0;
+ }
let store = FileStatusStore::new(open_session_stores(workspace).kv);
tinyagents_harness::observability::reap_orphaned_runs(&store).await
}