Skip to content

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

chore: files changed crates/openhuman-core/src/core/runtime/context_tests.rs

Steven Enamakel5292ccc763e4
diff --git a/crates/openhuman-core/src/core/runtime/context_tests.rs b/crates/openhuman-core/src/core/runtime/context_tests.rs
index 6d07b63fe2..fce468b7b0 100644
--- a/crates/openhuman-core/src/core/runtime/context_tests.rs
+++ b/crates/openhuman-core/src/core/runtime/context_tests.rs
@@ -84,6 +84,27 @@ async fn the_current_dispatch_sees_the_scoped_embedder_config() {
assert_eq!(scoped.workspace_dir, PathBuf::from("/tmp/scoped-ws"));
}
+#[tokio::test]
+async fn the_current_embedder_config_can_be_read_without_cloning_it() {
+ // `with_current_embedder_config` is the borrow-only twin of
+ // `current_embedder_config`: same scoped config, projected through a closure.
+ let mut config = crate::config::Config::default();
+ config.workspace_dir = PathBuf::from("/tmp/borrowed-ws");
+
+ let read = CoreContext::scope(ctx_with_config(config), async {
+ CoreContext::with_current_embedder_config(|c| c.workspace_dir.clone())
+ })
+ .await;
+ assert_eq!(read, Some(PathBuf::from("/tmp/borrowed-ws")));
+
+ // Without an embedder config the closure never runs.
+ let none = CoreContext::scope(ctx("/tmp/no-embedder-ws"), async {
+ CoreContext::with_current_embedder_config(|_| panic!("no config to read"))
+ })
+ .await;
+ assert_eq!(none, None::<()>);
+}
+
// ---- derived per-agent contexts (the multi-agent library seam) -----------
//
// `derive_with` is how one booted runtime hosts many independently configured