Skip to content

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

refactor(storage): update workspace session provider logic

Steven Enamakel056e36f19d54
diff --git a/crates/openhuman-core/src/agent/goals/mod.rs b/crates/openhuman-core/src/agent/goals/mod.rs
index 51ef1f512d..80c4e54b5c 100644
--- a/crates/openhuman-core/src/agent/goals/mod.rs
+++ b/crates/openhuman-core/src/agent/goals/mod.rs
@@ -40,7 +40,7 @@ pub fn goal_store(
}
let owner_stores = match context.tenant() {
- Ok(tenant) => crate::storage::sessions::provider_for_workspace(workspace_dir)
+ Ok(tenant) => crate::storage::sessions::provider_for_workspace_in(workspace_dir, context)
.for_agent(&crate::core::runtime::session_key(&tenant)),
Err(no_tenant) => {
log::warn!("[thread_goals] {no_tenant}; using throwaway in-memory store");
diff --git a/crates/openhuman-core/src/storage/sessions/mod.rs b/crates/openhuman-core/src/storage/sessions/mod.rs
index ad6c2f2f92..2d1e0bd2a1 100644
--- a/crates/openhuman-core/src/storage/sessions/mod.rs
+++ b/crates/openhuman-core/src/storage/sessions/mod.rs
@@ -27,7 +27,7 @@ pub use rebound::{rebind_all, ReboundSessionStores, StoreRegistry};
pub use tenant_router::TenantSessionStores;
pub use workspace::{
artifact_blobs_for, attachment_stash_for, current_documents_for, default_turn_states_for,
- ledger_for, provider_for_workspace, release_workspace, release_workspace_defaults,
+ ledger_for, provider_for_workspace, provider_for_workspace_in, release_workspace, release_workspace_defaults,
require_ledger, session_scope, status_store_for, stores_for, stores_or_ephemeral,
turn_states_for, with_ledger, with_ledger_async, WorkspaceSessionStores,
};
diff --git a/crates/openhuman-core/src/storage/sessions/workspace.rs b/crates/openhuman-core/src/storage/sessions/workspace.rs
index b342643f9a..3d75e85c75 100644
--- a/crates/openhuman-core/src/storage/sessions/workspace.rs
+++ b/crates/openhuman-core/src/storage/sessions/workspace.rs
@@ -69,6 +69,19 @@ pub fn provider_for_workspace(workspace_dir: &Path) -> Arc<dyn SessionStoreProvi
}
}
+/// The provider selected by `context` for `workspace_dir`, else the workspace
+/// fallback. This preserves agent-local host overrides when work carries an
+/// explicit dispatch context rather than the ambient task context.
+pub fn provider_for_workspace_in(
+ workspace_dir: &Path,
+ context: &crate::core::runtime::DispatchCtx,
+) -> Arc<dyn SessionStoreProvider> {
+ match super::installed_in(context) {
+ Some(installed) => installed,
+ None => fallback_provider(workspace_dir),
+ }
+}
+
/// The provider over `workspace_dir`'s default backend, installed or not.
pub(super) fn fallback_provider(workspace_dir: &Path) -> Arc<dyn SessionStoreProvider> {
let backend = match crate::storage::local::backend_for(workspace_dir) {