Skip to content

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

fix(subagent_host): prefer driver cost source and drop observer-cancel shortcut

Steven Enamakelce7419162994
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_adapter.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_adapter.rs
index 6066a111ed..fff797e867 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_adapter.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_adapter.rs
@@ -396,7 +396,9 @@ pub(in crate::agent::subagent_host) fn outcome_to_host(
.charged_amount
.map(|amount| amount.micros as f64 / 1_000_000.0)
.unwrap_or_default(),
- cost_source: cost_source_of(outcome.usage.usage.charged_amount.as_ref()),
+ cost_source: outcome.cost_source.unwrap_or_else(|| {
+ cost_source_of(outcome.usage.usage.charged_amount.as_ref())
+ }),
},
artifact_paths: outcome
.artifacts
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_result.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_result.rs
index d2f5b4fa57..066e46d2da 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_result.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_result.rs
@@ -39,16 +39,6 @@ pub(crate) async fn resolve_inline_driver_outcome(
.unwrap_or_else(|poisoned| poisoned.into_inner())
.remove(task_key);
- // Observer cancellation is invocation-local: the TinyAgents in-flight
- // follower has already stopped waiting and must not be replaced by a
- // leader's terminal result committed before this adapter runs. Preserve
- // the original disposition before consulting durable state.
- if let Some(outcome) = cached.as_ref().filter(|host| {
- host.persistence_disposition == SubagentPersistenceDisposition::ObserverCancelled
- }) {
- return Ok((outcome.clone(), public_job_id));
- }
-
// The driver's persistence CAS result is authoritative. Another
// invocation can win terminal/pause persistence while this executor's
// host-side cache still contains its local loser. Read the same scoped
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rs
index c0ba94a8db..a36957d64a 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rs
@@ -543,7 +543,10 @@ async fn legacy_pause_migration_does_not_return_a_stale_pause_after_terminal_com
.migrate_legacy_pause(&key, stale_pause)
.await
.unwrap();
- assert_eq!(migrated.output, "terminal winner");
+ assert!(
+ migrated.is_none(),
+ "terminal CAS winner must close the stale pause"
+ );
}
#[tokio::test]
@@ -647,8 +650,7 @@ async fn observer_cancel_survives_a_leader_commit_before_host_projection() {
let mut leader = SubagentOutcome::cancelled("task");
leader.status = SubagentOutcomeKind::Completed;
leader.output = "leader result".into();
- bundle
- .persistence
+ OpenHumanPersistence::new(directory.path().join("checkpoints"))
.record_terminal(&key, &leader, None)
.await
.unwrap();