Skip to content

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

refactor(agent): simplify turn origin lookup

Steven Enamakel86aec1f56352
diff --git a/crates/openhuman-core/src/agent/turn_origin.rs b/crates/openhuman-core/src/agent/turn_origin.rs
index f73be3d5ef..52928cec30 100644
--- a/crates/openhuman-core/src/agent/turn_origin.rs
+++ b/crates/openhuman-core/src/agent/turn_origin.rs
@@ -221,9 +221,12 @@ async fn scope_origin<F: std::future::Future>(origin: AgentTurnOrigin, fut: F) -
/// (legacy callers that haven't been migrated yet — the gate maps this to
/// [`AgentTurnOrigin::Unknown`] / fail-closed).
pub fn current() -> Option<AgentTurnOrigin> {
- crate::core::runtime::CoreContext::scoped()
- .and_then(|_| crate::core::runtime::CoreContext::current_turn_origin())
- .or_else(|| AGENT_TURN_ORIGIN.try_with(|o| o.clone()).ok())
+ if crate::core::runtime::CoreContext::scoped().is_some()
+ && let Some(origin) = crate::core::runtime::CoreContext::current_turn_origin()
+ {
+ return Some(origin);
+ }
+ AGENT_TURN_ORIGIN.try_with(|o| o.clone()).ok()
}
/// Capture the ambient origin so it can be carried across a `tokio::spawn`