Skip to content

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

refactor(artifacts): simplify artifact store construction

Steven Enamakela165535b08b3
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 ede5bf4bb1..499028e601 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -283,7 +283,7 @@ impl OpenHumanSessionHost {
tool_result_budget_bytes,
payload_summarizer: self.payload_summarizer.clone().filter(|_| juice_on),
// Rooted outside the project; see `artifact_wiring` (#6408, #6483).
- artifact_store: Some(artifact_store),
+ artifact_store,
tokenjuice_compaction_enabled: tokenjuice_compaction_enabled && juice_on,
tokenjuice_compression: self.tokenjuice_compression,
runtime_config: self.runtime_config.clone(),
diff --git a/crates/openhuman-core/src/artifacts/artifact_wiring.rs b/crates/openhuman-core/src/artifacts/artifact_wiring.rs
index 865b28d9e3..e03dc479ef 100644
--- a/crates/openhuman-core/src/artifacts/artifact_wiring.rs
+++ b/crates/openhuman-core/src/artifacts/artifact_wiring.rs
@@ -12,12 +12,9 @@
//! sweep below keeps bounded.
use std::path::Path;
-use std::sync::Arc;
-
use crate::agent::harness::tool_result_artifacts::{new_tool_result_store, HostArtifactStore};
use crate::security::policy::tool_result_artifacts_dir;
use crate::storage::sessions::artifact_blobs_for;
-use tinystoragedrivers::{MemoryStorage, Scope, StorageBackend};
/// How long a tool-result artifact survives: the blob lifetime handed to
/// drivers with blob TTL, and the age past which another session's
@@ -45,28 +42,20 @@ const ARTIFACT_RETENTION: std::time::Duration = std::time::Duration::from_secs(2
/// other sessions' stale materialised copies on the way.
///
/// With no blob store for the tenant (a SaaS task with no scope, a refused
-/// backend) the artifacts live in a private in-memory store for this process,
-/// so a large result is still stored and readable within the run.
+/// backend), return `None`; the harness keeps the result inline instead of
+/// silently moving it to process-local storage.
///
/// The sweep is best-effort by design: a failed prune must never fail a turn,
/// because the worst it costs is disk, while failing the turn costs the user
/// their message.
-pub(crate) fn build_artifact_store(workspace_dir: &Path, session_key: &str) -> HostArtifactStore {
- let blobs = artifact_blobs_for(workspace_dir).unwrap_or_else(|| {
- tracing::warn!(
- "[agent][tool-result-artifacts] no blob store for the acting tenant — artifacts stay in memory for this process"
- );
- let scope = Scope::new("local").expect("static scope");
- Arc::clone(
- MemoryStorage::new()
- .for_scope(&scope)
- .expect("memory scope")
- .blobs(),
- )
- });
+pub(crate) fn build_artifact_store(
+ workspace_dir: &Path,
+ session_key: &str,
+) -> Option<HostArtifactStore> {
+ let blobs = artifact_blobs_for(workspace_dir)?;
let root = tool_result_artifacts_dir(workspace_dir);
prune_materialized(&root, ARTIFACT_RETENTION);
- new_tool_result_store(blobs, root, session_key).with_retention(ARTIFACT_RETENTION)
+ Some(new_tool_result_store(blobs, root, session_key).with_retention(ARTIFACT_RETENTION))
}
/// The newest modification time anywhere under `path`, itself included.
diff --git a/crates/openhuman-core/src/artifacts/artifact_wiring_tests.rs b/crates/openhuman-core/src/artifacts/artifact_wiring_tests.rs
index 7c293fd93f..874bce1c15 100644
--- a/crates/openhuman-core/src/artifacts/artifact_wiring_tests.rs
+++ b/crates/openhuman-core/src/artifacts/artifact_wiring_tests.rs
@@ -48,7 +48,7 @@ fn stale_session(root: &Path, session: &str) -> std::path::PathBuf {
async fn the_store_materialises_in_the_workspace_not_the_action_dir() {
let tmp = tempfile::tempdir().unwrap();
let workspace = tmp.path().join("workspace");
- let store = build_artifact_store(&workspace, "s");
+ let store = build_artifact_store(&workspace, "s").expect("workspace backend is available");
assert_eq!(
store.materialize_root(),
tool_result_artifacts_dir(&workspace)
@@ -63,7 +63,7 @@ async fn the_store_materialises_in_the_workspace_not_the_action_dir() {
async fn a_stored_result_survives_a_session_reload() {
let tmp = tempfile::tempdir().unwrap();
let workspace = tmp.path().join("workspace");
- let first = build_artifact_store(&workspace, "thread-1");
+ let first = build_artifact_store(&workspace, "thread-1").expect("workspace backend is available");
let raw = "z".repeat(4096);
let (out, outcome) =
apply_per_result_persistence(raw, None, Some(&first), "shell", Some("call-1"), 1024).await;
@@ -74,7 +74,7 @@ async fn a_stored_result_survives_a_session_reload() {
"{key}"
);
- let reloaded = build_artifact_store(&workspace, "thread-1");
+ let reloaded = build_artifact_store(&workspace, "thread-1").expect("workspace backend is available");
let mut args = json!({"path": key});
reloaded
.resolve_read(
@@ -108,7 +108,7 @@ fn workspace_retention_leaves_legacy_project_artifacts_alone() {
.build()
.unwrap();
let _guard = rt.enter();
- build_artifact_store(&workspace, "current");
+ let _ = build_artifact_store(&workspace, "current");
assert!(
stale.exists(),