Skip to content

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

refactor(storage): adjust artifact scope derivation in workspace

Steven Enamakel08887f0437db
diff --git a/crates/openhuman-core/src/storage/sessions/workspace.rs b/crates/openhuman-core/src/storage/sessions/workspace.rs
index 17bffaf630..717e492a91 100644
--- a/crates/openhuman-core/src/storage/sessions/workspace.rs
+++ b/crates/openhuman-core/src/storage/sessions/workspace.rs
@@ -229,16 +229,12 @@ pub fn artifact_scoped_for_in(
return None;
}
};
- // Artifacts are shared across the profile, like the artifacts domain's
- // existing document records. Session state is agent-scoped, so using its
- // session key here would strand records in a narrower namespace.
- let agent = tenant
- .agent
- .as_deref()
- .filter(|agent| tenant.profile.is_none() && *agent != super::DEFAULT_AGENT);
+ // Match the storage domain's established scope for this tenant. Session
+ // keys encode a default agent even when the storage scope is local, so do
+ // not derive artifact scope from the session key.
let scope = match crate::storage::scope_from(
tenant.profile.as_deref(),
- agent,
+ tenant.agent.as_deref(),
crate::core::runtime::mode::is_saas(),
) {
Ok(scope) => scope,
diff --git a/crates/openhuman-core/src/storage/sessions/workspace_tests.rs b/crates/openhuman-core/src/storage/sessions/workspace_tests.rs
index 9e7a0e04f0..4b2c7dfaf6 100644
--- a/crates/openhuman-core/src/storage/sessions/workspace_tests.rs
+++ b/crates/openhuman-core/src/storage/sessions/workspace_tests.rs
@@ -108,6 +108,14 @@ fn artifact_scope_uses_agent_scope_only_for_unprofiled_named_agents() {
let default_agent = artifact_scoped_for_in(ws.path(), &context_for(None))
.expect("the default agent has the local scope");
assert!(default_agent.scope().is_local());
+
+ let explicitly_named_default =
+ artifact_scoped_for_in(ws.path(), &context_for(Some(super::DEFAULT_AGENT)))
+ .expect("an explicitly named agent uses the agent scope");
+ assert_eq!(
+ explicitly_named_default.scope(),
+ &crate::storage::scope_for_agent(super::DEFAULT_AGENT)
+ );
}
#[test]