Skip to content

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

feat(subagent-host): load persisted terminal outcome by task key

Steven Enamakel7ae0243eb3a0
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
index 4ff1aa5c75..09ae4cccb1 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
@@ -58,6 +58,21 @@ pub(crate) fn detached_subagent_parent(
.map_err(|error| anyhow::anyhow!(error.to_string()))
}
+/// Read the typed terminal written for one exact driver lifecycle key.
+/// Cancellation uses this rather than inferring success from the product
+/// session's lossy `Idle` status (which also represents incomplete runs).
+pub(crate) fn load_terminal_outcome(
+ workspace_dir: &std::path::Path,
+ key: &SubagentTaskKey,
+) -> Result<Option<SubagentOutcome>, String> {
+ let checkpoint_dir = absolute_checkpoint_dir(
+ workspace_dir.join(".openhuman/subagent_checkpoints"),
+ );
+ OpenHumanPersistence::new(checkpoint_dir)
+ .terminal_outcome(key)
+ .map_err(|error| format!("failed to load subagent terminal outcome: {error}"))
+}
+
/// Runs one host subagent through a neutral driver using a real direct child.
///
/// Callers that are already inside a TinyAgents turn must use this entrypoint:
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle/persistence.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle/persistence.rs
index 581a3bcd5e..8129afe733 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle/persistence.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle/persistence.rs
@@ -290,6 +290,14 @@ impl OpenHumanPersistence {
}
}
+ pub(super) fn terminal_outcome(
+ &self,
+ key: &SubagentTaskKey,
+ ) -> Result<Option<SubagentOutcome>, SubagentError> {
+ let _key_lock = self.key_lock(key)?;
+ Ok(self.read_terminal_record(key)?.map(|record| record.outcome))
+ }
+
pub(super) fn durable_host_metadata(
&self,
key: &SubagentTaskKey,
diff --git a/crates/openhuman-core/src/agent/subagent_host/mod.rs b/crates/openhuman-core/src/agent/subagent_host/mod.rs
index 176ee8448c..0991d40c91 100644
--- a/crates/openhuman-core/src/agent/subagent_host/mod.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/mod.rs
@@ -57,6 +57,7 @@ mod persisted_compat_tests;
// Public API — the entry point and the shapes it returns.
pub use autonomous::{definition_iter_cap, subagent_iter_cap_with_autonomous_lift};
pub(crate) use lifecycle::detached_subagent_parent;
+pub(crate) use lifecycle::load_terminal_outcome;
pub(crate) use lifecycle::load_subagent_checkpoint;
pub(crate) use lifecycle::run_configured_delegate_via_driver_tool;
pub(crate) use lifecycle::run_subagent_via_driver_tool;