Skip to content

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

refactor(sandbox): thread dispatch context through sandbox policy resolution

Steven Enamakel6c717c916cc8
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/code.rs b/crates/openhuman-core/src/flows/tinyflows/caps/code.rs
index ac052d3f04..62e69bfee6 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/code.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/code.rs
@@ -83,8 +83,11 @@ impl CodeRunner for OpenHumanCode {
return Err(EngineError::Capability(reason));
}
+ // Transitional (#7801): the flow caps carry no context yet.
+ let dispatch = DispatchCtx::ambient();
let outcome: Result<Value> = async {
let policy = resolve_sandbox_policy(
+ &dispatch,
SandboxMode::Sandboxed,
&self.config.action_dir,
&self.config.workspace_dir,
@@ -148,7 +151,7 @@ impl CodeRunner for OpenHumanCode {
"[flows] code: running sandboxed script"
);
- execute_in_sandbox(&DispatchCtx::ambient(),
+ execute_in_sandbox(&dispatch,
&policy,
&command,
&self.config.action_dir,
diff --git a/crates/openhuman-core/src/sandbox/ops_tests.rs b/crates/openhuman-core/src/sandbox/ops_tests.rs
index 43e45076d3..5e6c8a4f5c 100644
--- a/crates/openhuman-core/src/sandbox/ops_tests.rs
+++ b/crates/openhuman-core/src/sandbox/ops_tests.rs
@@ -365,7 +365,7 @@ async fn sandbox_off_component_forces_the_unsandboxed_fallback_and_no_module_loa
let ctx = crate::core::runtime::context::CoreContext::for_test_with_components(set);
let dispatch = DispatchCtx::new(ctx.clone());
crate::core::runtime::context::CoreContext::scope(ctx, async {
- assert!(sandbox_component_off());
+ assert!(sandbox_component_off(&dispatch));
assert!(sandbox_disabled_by_host());
assert!(
!command_requires_sandbox(&dispatch, Some(SandboxMode::Sandboxed))
@@ -378,12 +378,12 @@ async fn sandbox_off_component_forces_the_unsandboxed_fallback_and_no_module_loa
#[tokio::test]
async fn sandbox_component_is_on_without_a_context_or_when_enabled() {
- assert!(!sandbox_component_off());
+ assert!(!sandbox_component_off(&DispatchCtx::ambient()));
let ctx = crate::core::runtime::context::CoreContext::for_test_with_components(
crate::core::runtime::ComponentSet::all(),
);
crate::core::runtime::context::CoreContext::scope(ctx, async {
- assert!(!sandbox_component_off());
+ assert!(!sandbox_component_off(&DispatchCtx::ambient()));
})
.await;
}