Skip to content

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

chore(session): tidy session store, bootstrap, and recovery internals

Steven Enamakel42385c705920
diff --git a/crates/openhuman-core/src/agent/session_store/mod.rs b/crates/openhuman-core/src/agent/session_store/mod.rs
index 91c695e482..da2ee00c34 100644
--- a/crates/openhuman-core/src/agent/session_store/mod.rs
+++ b/crates/openhuman-core/src/agent/session_store/mod.rs
@@ -82,11 +82,20 @@ pub fn restore(provider: Option<Arc<dyn SessionStoreProvider>>) {
*PROVIDER.write().unwrap_or_else(PoisonError::into_inner) = provider;
}
-/// The provider in effect: the context's host-override one, else the
-/// installed one, if any.
+/// The provider in effect for the calling task's ambient context: see
+/// [`installed_in`].
#[must_use]
pub fn installed() -> Option<Arc<dyn SessionStoreProvider>> {
- crate::core::runtime::CoreContext::current_host_overrides()
+ installed_in(&crate::core::runtime::DispatchCtx::ambient())
+}
+
+/// The provider in effect for `ctx`: the host-override one of the agent it
+/// runs for, else the installed one, if any.
+#[must_use]
+pub fn installed_in(
+ ctx: &crate::core::runtime::DispatchCtx,
+) -> Option<Arc<dyn SessionStoreProvider>> {
+ ctx.host_overrides()
.and_then(|local| local.session_store.clone())
.or_else(|| {
PROVIDER
diff --git a/crates/openhuman-core/src/core/runtime/bootstrap.rs b/crates/openhuman-core/src/core/runtime/bootstrap.rs
index 01b21905a2..c002ae98e8 100644
--- a/crates/openhuman-core/src/core/runtime/bootstrap.rs
+++ b/crates/openhuman-core/src/core/runtime/bootstrap.rs
@@ -97,7 +97,7 @@ pub(crate) async fn bootstrap_core_runtime(
//
// An installed host session store repairs itself, once; with none, the
// workspace default store is swept.
- let host_store = crate::agent::session_store::installed();
+ let host_store = crate::agent::session_store::installed_in(&DispatchCtx::ambient());
if let Some(provider) = &host_store {
match provider.recover() {
Ok(()) => log::info!("[runtime] host session store recovered"),
diff --git a/crates/openhuman-core/src/profiles/recovery.rs b/crates/openhuman-core/src/profiles/recovery.rs
index ac44891073..6a202409ae 100644
--- a/crates/openhuman-core/src/profiles/recovery.rs
+++ b/crates/openhuman-core/src/profiles/recovery.rs
@@ -29,7 +29,9 @@ pub(crate) fn recover_workspace(id: &ProfileId, workspace_dir: &std::path::Path)
/// store, which the workspace sweep cannot see: the profile's default
/// session key is swept through the installed provider.
pub(crate) fn recover_session_store(id: &ProfileId, context: &Arc<CoreContext>) {
- let Some(provider) = crate::agent::session_store::installed() else {
+ let Some(provider) = crate::agent::session_store::installed_in(
+ &crate::core::runtime::DispatchCtx::new(Arc::clone(context)),
+ ) else {
return;
};
if provider.workspace_dir().is_some() {