Skip to content

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

chore: files changed crates/openhuman-core/src/agent/subagent_host/lifecycle_checkpoint.rs

Steven Enamakel2cd09e115a91
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle_checkpoint.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle_checkpoint.rs
index 91b0a843be..7a1af8b687 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle_checkpoint.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle_checkpoint.rs
@@ -2,16 +2,35 @@
use std::path::PathBuf;
+/// The in-flight reservation map is keyed by this path, so it must name a
+/// directory identically before and after the lifecycle store creates it.
+/// Canonicalizing the whole path only once it exists would resolve symlinked
+/// parents (macOS `/var` -> `/private/var`) for a late caller but not an early
+/// one, putting two callers of one task in different flights. Resolve the
+/// deepest existing ancestor and re-append the not-yet-created tail instead.
pub(super) fn absolute_checkpoint_dir(path: PathBuf) -> PathBuf {
- std::fs::canonicalize(&path).unwrap_or_else(|_| {
- if path.is_absolute() {
- path
- } else {
- std::env::current_dir()
- .map(|cwd| cwd.join(&path))
- .unwrap_or(path)
+ let absolute = if path.is_absolute() {
+ path
+ } else {
+ match std::env::current_dir() {
+ Ok(cwd) => cwd.join(&path),
+ Err(_) => path,
}
- })
+ };
+ let mut tail = Vec::new();
+ let mut ancestor = absolute.as_path();
+ loop {
+ if let Ok(resolved) = std::fs::canonicalize(ancestor) {
+ return tail.iter().rev().fold(resolved, |dir, name| dir.join(name));
+ }
+ match (ancestor.file_name(), ancestor.parent()) {
+ (Some(name), Some(parent)) => {
+ tail.push(name.to_owned());
+ ancestor = parent;
+ }
+ _ => return absolute,
+ }
+ }
}
#[cfg(test)]