Skip to content

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

test(cost): bind a core context in the ambient scope test

Steven Enamakel70af9016a28f
diff --git a/crates/openhuman-core/src/platform/cost/scope_tests.rs b/crates/openhuman-core/src/platform/cost/scope_tests.rs
index 4a4e840c1d..5751972c45 100644
--- a/crates/openhuman-core/src/platform/cost/scope_tests.rs
+++ b/crates/openhuman-core/src/platform/cost/scope_tests.rs
@@ -47,15 +47,22 @@ async fn ambient_scope_reads_the_turn_and_prefers_the_subagent() {
client_id: "c".into(),
request_id: None,
};
- let (parent, child) = crate::agent::turn_origin::with_origin(origin, async {
- within(MemoryIdentity::agent("orchestrator"), async {
- (
- UsageScope::ambient(Some("openhuman"), None),
- UsageScope::ambient(Some("openhuman"), Some(("researcher", "task-1"))),
- )
- })
- .await
- })
+ // The origin is read from the turn's `CoreContext`, which `with_origin`
+ // binds when there is a context to bind it on.
+ let ctx =
+ crate::core::runtime::CoreContext::for_test(crate::core::runtime::DomainSet::full(), None);
+ let (parent, child) = crate::core::runtime::CoreContext::scope(
+ ctx,
+ crate::agent::turn_origin::with_origin(origin, async {
+ within(MemoryIdentity::agent("orchestrator"), async {
+ (
+ UsageScope::ambient(Some("openhuman"), None),
+ UsageScope::ambient(Some("openhuman"), Some(("researcher", "task-1"))),
+ )
+ })
+ .await
+ }),
+ )
.await;
assert_eq!(parent.thread_id.as_deref(), Some("thread-9"));
assert_eq!(parent.origin.as_deref(), Some("web_chat"));