Skip to content

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

fix(subagent_host): preserve terminal record metadata in outcomes

Steven Enamakelc8a3d0acc905
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 b4c52de4bf..622b5e15ed 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle/persistence.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle/persistence.rs
@@ -14,6 +14,8 @@ struct TerminalRecord {
agent_id: String,
#[serde(default)]
elapsed_ms: u64,
+ #[serde(flatten)]
+ extensions: std::collections::BTreeMap<String, serde_json::Value>,
}
#[derive(serde::Deserialize)]
@@ -360,6 +362,26 @@ impl OpenHumanPersistence {
}
}
+ fn into_outcome(record: TerminalRecord) -> SubagentOutcome {
+ let mut outcome = record.outcome;
+ if !record.agent_id.is_empty() {
+ outcome
+ .extensions
+ .entry("agent_id".into())
+ .or_insert_with(|| serde_json::Value::String(record.agent_id));
+ }
+ if record.elapsed_ms != 0 {
+ outcome
+ .extensions
+ .entry("elapsed_ms".into())
+ .or_insert_with(|| serde_json::json!(record.elapsed_ms));
+ }
+ for (key, value) in record.extensions {
+ outcome.extensions.entry(key).or_insert(value);
+ }
+ outcome
+ }
+
pub(super) fn terminal_outcome(
&self,
key: &SubagentTaskKey,
@@ -367,7 +389,7 @@ impl OpenHumanPersistence {
if let Some(outcome) = self.store()?.terminal_outcome(key)? {
return Ok(Some(outcome));
}
- Ok(self.read_terminal_record(key)?.map(|record| record.outcome))
+ Ok(self.read_terminal_record(key)?.map(Self::into_outcome))
}
pub(super) fn durable_host_metadata(
@@ -577,7 +599,7 @@ impl tinyagents_orchestration::subagent::SubagentPersistence for OpenHumanPersis
if let Some(outcome) = self.store()?.terminal_outcome(key)? {
return Ok(Some(outcome));
}
- Ok(self.read_terminal_record(key)?.map(|record| record.outcome))
+ Ok(self.read_terminal_record(key)?.map(Self::into_outcome))
}
async fn load(&self, key: &SubagentTaskKey) -> Result<Option<SubagentResume>, SubagentError> {
if self.load_terminal(key).await?.is_some() {