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: bound subagent persistence filename components
Steven Enamakel25b251bd55ee
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rsindex 0b09c333f5..ff07b3b26a 100644--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs@@ -14,6 +14,7 @@ use std::{use async_trait::async_trait;use fs2::FileExt;+use sha2::{Digest, Sha256};use tinyagents_harness::context::{RunConfig, RunContext};use tinyagents_orchestration::subagent::{ArtifactReference, PreparedSubagent, SubagentCapabilities, SubagentDriver, SubagentError,@@ -592,13 +593,24 @@ impl OpenHumanPersistence {.map(|byte| format!("{byte:02x}")).collect()}- format!(+ let encoded = format!("{}-{}-{}-{}",hex(&key.root_run_id),hex(&key.parent_run_id),hex(key.thread_id.as_deref().unwrap_or("")),hex(&key.task_id),- )+ );+ // A task key normally contains short UUID-like identifiers, for which+ // the reversible encoding preserves existing checkpoint paths. A+ // background child may inherit a rendered parent identifier, however;+ // hex-encoding that value can exceed the filesystem filename limit.+ // Hash only that exceptional form while keeping all key fields in the+ // digest input so distinct lifecycle scopes cannot alias.+ if encoded.len() <= 180 {+ encoded+ } else {+ format!("sha256-{:x}", Sha256::digest(encoded.as_bytes()))+ }}fn pause_path(&self, key: &SubagentTaskKey) -> std::path::PathBuf {@@ -614,14 +626,9 @@ impl OpenHumanPersistence {}fn index_path(&self, task_id: &str) -> std::path::PathBuf {- self.checkpoint_dir.join("lifecycle").join(format!(- "task-{}.index.json",- task_id- .as_bytes()- .iter()- .map(|byte| format!("{byte:02x}"))- .collect::<String>()- ))+ self.checkpoint_dir+ .join("lifecycle")+ .join(format!("task-{}.index.json", Self::task_component(task_id)))}fn lock_path(&self, key: &SubagentTaskKey) -> std::path::PathBuf {@@ -631,14 +638,22 @@ impl OpenHumanPersistence {}fn index_lock_path(&self, task_id: &str) -> std::path::PathBuf {- self.checkpoint_dir.join("lifecycle").join(format!(- "task-{}.index.lock",- task_id- .as_bytes()- .iter()- .map(|byte| format!("{byte:02x}"))- .collect::<String>()- ))+ self.checkpoint_dir+ .join("lifecycle")+ .join(format!("task-{}.index.lock", Self::task_component(task_id)))+ }++ fn task_component(task_id: &str) -> String {+ let encoded = task_id+ .as_bytes()+ .iter()+ .map(|byte| format!("{byte:02x}"))+ .collect::<String>();+ if encoded.len() <= 180 {+ encoded+ } else {+ format!("sha256-{:x}", Sha256::digest(encoded.as_bytes()))+ }}fn lock_file(path: &std::path::Path) -> Result<std::fs::File, SubagentError> {diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rsindex 964110a60e..8864b490bb 100644--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rs@@ -75,6 +75,25 @@ fn resume_history_keeps_the_durable_transcript_and_appends_user_answer_once() {);}+#[tokio::test]+async fn persistence_hashes_an_oversized_scoped_key_for_filesystem_safety() {+ let directory = tempfile::tempdir().unwrap();+ let persistence = OpenHumanPersistence::new(directory.path().to_path_buf());+ let key = SubagentTaskKey {+ root_run_id: "root".repeat(100),+ parent_run_id: "parent".repeat(100),+ thread_id: Some("thread".repeat(100)),+ task_id: "task".repeat(100),+ };++ persistence+ .save_pause(persisted_pause(key.clone(), "question", None))+ .await+ .unwrap();++ assert!(persistence.load_pause(&key).await.unwrap().is_some());+}+#[tokio::test]async fn persistence_commits_one_scoped_pause_and_recovers_its_original_key() {let directory = tempfile::tempdir().unwrap();