Skip to content

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

refactor(core): improve artifact storage and tokenjuice configuration

Steven Enamakel4f0d4dce8e85
diff --git a/crates/openhuman-core/src/artifacts/tiny_store.rs b/crates/openhuman-core/src/artifacts/tiny_store.rs
index 860b8a2961..2e06de89e3 100644
--- a/crates/openhuman-core/src/artifacts/tiny_store.rs
+++ b/crates/openhuman-core/src/artifacts/tiny_store.rs
@@ -302,10 +302,18 @@ pub fn artifacts_service(
chat: Option<&ApprovalChatContext>,
) -> Artifacts {
let roots = file_roots(workspace_dir, &files, action_dir);
- Artifacts::new(Arc::new(versioned_store(workspace_dir)))
+ let service = Artifacts::new(Arc::new(versioned_store(workspace_dir)))
.with_observer(Arc::new(LegacyUiBridge::new(workspace_dir, files, chat)))
- .with_file_roots(guarded_roots(roots))
- .with_version_files(version_files_dir(workspace_dir))
+ .with_file_roots(guarded_roots(roots));
+ match crate::storage::local::open("artifacts::files", workspace_dir)
+ .and_then(|opened| opened.scoped())
+ {
+ Ok(scoped) => service.with_file_store(Arc::new(tiny_artifacts::BlobFileStore::new(&scoped))),
+ Err(error) => {
+ log::warn!("[artifacts] file storage unavailable: {error:#}");
+ service
+ }
+ }
}
/// Where each file version keeps its own copy:
diff --git a/crates/openhuman-core/src/inference/tokenjuice/mod.rs b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
index 5c75a22f79..b90bdc7968 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/mod.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
@@ -117,17 +117,12 @@ pub(crate) fn install_request(config: &crate::config::Config) -> InstallRequest
llm_summary_threshold_tokens: config.context.summarizer_payload_threshold_tokens,
llm_summary_max_input_tokens: config.context.summarizer_max_payload_tokens,
repl_handle: repl_handle_active(config),
- repl_save_dir: (repl_handle_active(config) && tj.repl_save_enabled)
- .then(|| repl_save_dir(&config.workspace_dir)),
..tinyjuice_bus::types::CompressOptions::default()
},
max_cache_entries: tj.max_cache_entries,
max_cache_bytes: tj.max_cache_bytes,
ccr_ttl_secs: tj.ccr_ttl_secs,
- disk_tier_root: tj
- .ccr_disk_enabled
- .then(|| config.workspace_dir.join(".tokenjuice").join("ccr"))
- .map(|path| path.to_string_lossy().into_owned()),
+ ccr_durable: tj.ccr_disk_enabled,
}
}
@@ -153,10 +148,11 @@ pub async fn install_from_config(config: &crate::config::Config) -> Result<(), S
let request = install_request(config);
// The module keeps the durable tier on its blob storage; originals the old
// disk tier wrote move across first (once per directory, best effort).
- if let Some(root) = request.disk_tier_root.as_deref() {
+ if config.tokenjuice.ccr_disk_enabled {
+ let root = config.workspace_dir.join(".tokenjuice").join("ccr");
crate::modules::import_legacy_tinyjuice(
&crate::core::runtime::DispatchCtx::ambient(),
- std::path::Path::new(root),
+ &root,
request.ccr_ttl_secs.map(std::time::Duration::from_secs),
)
.await;
diff --git a/crates/openhuman-core/src/storage/sessions/workspace.rs b/crates/openhuman-core/src/storage/sessions/workspace.rs
index 7cd23a3a62..81e14bb3a5 100644
--- a/crates/openhuman-core/src/storage/sessions/workspace.rs
+++ b/crates/openhuman-core/src/storage/sessions/workspace.rs
@@ -210,7 +210,11 @@ pub fn artifact_blobs_for(workspace_dir: &Path) -> Option<Arc<dyn BlobStore>> {
/// The calling tenant's scoped storage on `workspace_dir`'s backend. `what`
/// only labels the log line when the backend or scope is refused.
fn tenant_scope_for(workspace_dir: &Path, what: &str) -> Option<(String, ScopedStorage)> {
- let key = tenant_agent_key()?;
+ let key = match tenant_agent_key() {
+ Some(key) => key,
+ None if !crate::core::runtime::is_saas() => super::DEFAULT_AGENT.to_owned(),
+ None => return None,
+ };
let backend = match crate::storage::local::backend_for(workspace_dir) {
Ok(backend) => backend,
Err(error) => {