The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(artifact_offload): refuse materializing offload targets inside workspace state
Steven Enamakel175c0f801f8e
diff --git a/crates/openhuman-core/src/agent/cost_tests.rs b/crates/openhuman-core/src/agent/cost_tests.rsindex 8c8dfc0fb6..3afa83ef7a 100644--- a/crates/openhuman-core/src/agent/cost_tests.rs+++ b/crates/openhuman-core/src/agent/cost_tests.rs@@ -71,7 +71,11 @@ fn an_estimate_carried_on_the_usage_is_not_taken_for_a_charge() {#[test]fn a_turn_with_any_unknown_call_has_no_total() {let mut turn = turn_cost();- record(&mut turn, UNCATALOGUED, &counts(10, 1, 0).with_charged_usd(0.5));+ record(+ &mut turn,+ UNCATALOGUED,+ &counts(10, 1, 0).with_charged_usd(0.5),+ );assert_eq!(turn.total_usd(), Some(0.5));assert_eq!(turn.cost.source, CostSource::Charged);diff --git a/crates/openhuman-core/src/agent/harness/artifact_offload/artifact_offload_tests.rs b/crates/openhuman-core/src/agent/harness/artifact_offload/artifact_offload_tests.rsindex d82588bb2b..c7f0ba3cba 100644--- a/crates/openhuman-core/src/agent/harness/artifact_offload/artifact_offload_tests.rs+++ b/crates/openhuman-core/src/agent/harness/artifact_offload/artifact_offload_tests.rs@@ -115,36 +115,33 @@ fn memory_blobs() -> Arc<dyn tinystoragedrivers::BlobStore> {// ── Wiring (the point of `new_artifact_offload`) ──────────────────────────────#[tokio::test]-async fn a_wired_writer_refuses_a_target_inside_workspace_dir() {- // The fail-closed invariant, end to end: offload targets resolve under- // `action_dir`, never `workspace_dir`. Here `action_dir` is configured- // INSIDE the workspace root, so containment alone would pass and only the- // injected guard stands between an agent and core state.+async fn an_action_dir_inside_workspace_dir_is_never_materialized() {+ // The fail-closed invariant, end to end: the reader's copy lands under+ // `action_dir`, never in `workspace_dir`. Here `action_dir` is configured+ // INSIDE the workspace root, so only the host's check stands between an+ // agent and core state. The result stays inline and nothing is written.let dir = tempfile::tempdir().expect("tempdir");let workspace_dir = dir.path().to_path_buf();let action_dir = workspace_dir.join("action");std::fs::create_dir_all(&action_dir).expect("action dir");+ let policy = policy_with(action_dir.clone(), workspace_dir);- let offload = new_artifact_offload(- memory_blobs(),- Some(policy_with(- dir.path().join("action"),- workspace_dir.clone(),- )),- "agent",- "task",- );+ let offload = new_artifact_offload(memory_blobs(), Some(policy.clone()), "agent", "task");+ let big = "x".repeat(10_000);+ let (text, artifact) = offload_oversized_result(+ big.clone(),+ &offload,+ DEFAULT_OFFLOAD_THRESHOLD_BYTES,+ &action_dir,+ Some(&policy),+ )+ .await;- let err = offload- .write(ArtifactKind::Output, "leak.md", "x")- .await- .expect_err("a target inside workspace_dir must be refused");+ assert_eq!(text, big, "the inline payload must survive the refusal");+ assert!(artifact.is_none());assert!(- matches!(- err,- OffloadError::InternalRoot { .. } | OffloadError::InternalState { .. }- ),- "expected a workspace refusal, got {err:?}"+ !action_dir.join("outputs").exists(),+ "nothing may be materialized under workspace_dir");}@@ -202,14 +199,14 @@ async fn oversized_result_is_offloaded_and_the_parent_gets_a_readable_pointer());let big = "x".repeat(10_000);- let (text, artifact) =- offload_oversized_result(- big.clone(),- &offload,- DEFAULT_OFFLOAD_THRESHOLD_BYTES,- &action_dir,- )- .await;+ let (text, artifact) = offload_oversized_result(+ big.clone(),+ &offload,+ DEFAULT_OFFLOAD_THRESHOLD_BYTES,+ &action_dir,+ None,+ )+ .await;let artifact = artifact.expect("an artifact was written");assert!(text.starts_with(ARTIFACT_POINTER_PREFIX));@@ -220,7 +217,10 @@ async fn oversized_result_is_offloaded_and_the_parent_gets_a_readable_pointer()"pointer must name the host read tool: {text}");// And the path it quotes must be the one a parent can actually extract.- assert_eq!(extract_artifact_paths(&text), vec![artifact.relative_path.clone()]);+ assert_eq!(+ extract_artifact_paths(&text),+ vec![artifact.relative_path.clone()]+ );// The pointer's path is openable by `file_read` against the action root.let on_disk = tokio::fs::read_to_string(action_dir.join(&artifact.relative_path))@@ -243,6 +243,7 @@ async fn offload_failure_keeps_the_inline_payload_for_the_summarizer_fallback()&offload,DEFAULT_OFFLOAD_THRESHOLD_BYTES,&PathBuf::from("/proc/nonexistent-action-root"),+ None,).await;diff --git a/crates/openhuman-core/src/agent/harness/artifact_offload/mod.rs b/crates/openhuman-core/src/agent/harness/artifact_offload/mod.rsindex 9ff94093f2..fc71e8d482 100644--- a/crates/openhuman-core/src/agent/harness/artifact_offload/mod.rs+++ b/crates/openhuman-core/src/agent/harness/artifact_offload/mod.rs@@ -51,7 +51,7 @@ pub mod policy;use std::path::Path;use std::sync::Arc;-use tinyagents_harness::artifacts::ArtifactOffload;+use tinyagents_harness::artifacts::{ArtifactKind, ArtifactOffload};use tinystoragedrivers::BlobStore;use crate::security::SecurityPolicy;@@ -90,8 +90,8 @@ pub fn new_artifact_offload(agent_id: impl Into<String>,task_id: impl Into<String>,) -> ArtifactOffload {- let offload = ArtifactOffload::new(blobs, agent_id, task_id)- .with_redactor(Arc::new(SanitizingRedactor));+ let offload =+ ArtifactOffload::new(blobs, agent_id, task_id).with_redactor(Arc::new(SanitizingRedactor));match policy {Some(policy) => offload.with_path_policy(Arc::new(WorkspaceGuard::new(policy))),// No policy means the workspace checks are skipped; traversal and@@ -116,7 +116,25 @@ pub async fn offload_oversized_result(offload: &ArtifactOffload,threshold_bytes: usize,materialize_root: &Path,+ policy: Option<&SecurityPolicy>,) -> (String, Option<OffloadedArtifact>) {+ // The blob key is relative, so the crate's path policy cannot see where the+ // reader's copy will land. Refuse here, before anything is stored, a target+ // that would reach the core's internal state.+ if let Some(policy) = policy {+ if let Ok(key) = offload.resolve(ArtifactKind::Output, &offload.default_result_name()) {+ let target = materialize_root.join(&key);+ if policy.is_workspace_internal_path(&target)+ || target.starts_with(&policy.workspace_dir)+ {+ tracing::warn!(+ path = %key,+ "[artifact] materialized target reaches workspace state; keeping the inline result"+ );+ return (output, None);+ }+ }+ }let (pointer, artifact) = tinyagents_harness::artifacts::offload_oversized_result(output.clone(),offload,diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rsindex 697f99c349..97fb8ef59d 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs@@ -501,12 +501,13 @@ async fn offload_outcome_artifacts();return;};- let offload = new_artifact_offload(blobs, policy, outcome.agent_id.clone(), task_id);+ let offload = new_artifact_offload(blobs, policy.clone(), outcome.agent_id.clone(), task_id);let (output, _artifact) = offload_oversized_result(std::mem::take(&mut outcome.output),&offload,threshold,&materialize_root,+ policy.as_deref(),).await;outcome.output = output;diff --git a/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs b/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rsindex c62c11116c..3bf907c03f 100644--- a/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs+++ b/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs@@ -19,15 +19,15 @@ pub(super) fn install(StopHookMiddleware::new(model, hooks).with_metrics_seed(crate::agent::cost::turn_cost()).with_stop_observer(move |report| {- tracing::warn!(- target: "stop_hooks",- hook = %report.hook,- iteration = report.iteration,- model = %report.model,- "[stop_hooks] hook voted to stop the turn — pausing run: {}", report.reason- );- record_halt_summary(&halt_summary, report);- }),+ tracing::warn!(+ target: "stop_hooks",+ hook = %report.hook,+ iteration = report.iteration,+ model = %report.model,+ "[stop_hooks] hook voted to stop the turn — pausing run: {}", report.reason+ );+ record_halt_summary(&halt_summary, report);+ }),));}}