Skip to content

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

fix(caps_host): prefer host core context over dispatch ctx in agent harness

Steven Enamakel2edb5f90e992
diff --git a/crates/openhuman-core/src/flows/caps_host/agent_harness.rs b/crates/openhuman-core/src/flows/caps_host/agent_harness.rs
index 8b39abbf92..1fc92dc08e 100644
--- a/crates/openhuman-core/src/flows/caps_host/agent_harness.rs
+++ b/crates/openhuman-core/src/flows/caps_host/agent_harness.rs
@@ -126,7 +126,7 @@ impl OpenHumanAgentRunner {
let mut host_env = agent.host_env().clone();
// Harness turns can outlive the flow node's task-local scope when
// they spawn sub-agents. Carry the flow caller's owner explicitly.
- host_env.core = self.ctx.downgrade();
+ host_env.core = host_core_context(&self.ctx, host.as_ref().map(|host| &host.context));
host_env.turn_deadline = Some(deadline);
agent.set_host_env(host_env);
@@ -222,3 +222,16 @@ impl OpenHumanAgentRunner {
.await
}
}
+
+fn host_core_context(
+ dispatch: &crate::core::runtime::DispatchCtx,
+ host_context: Option<&std::sync::Arc<crate::core::runtime::CoreContext>>,
+) -> Option<std::sync::Weak<crate::core::runtime::CoreContext>> {
+ host_context
+ .map(std::sync::Arc::downgrade)
+ .or_else(|| dispatch.downgrade())
+}
+
+#[cfg(test)]
+#[path = "agent_harness_tests.rs"]
+mod tests;