Skip to content

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

fix(sandbox): clarify backend contract + use loaded config.action_dir\n\nReview follow-ups (#6081):\n- The sandbox_status backend input selects the sandbox MODE (docker/local ->\n sandboxed, none -> none); the concrete backend is resolved from the loaded\n runtime config + is_remote (what a real session gets). Rewrite the schema\n comment to say so rather than 'backend kind to check' — behaviour unchanged\n (do NOT reintroduce the #6081 conflation).\n- resolve_policy now passes config.action_dir (the loader-resolved value, which\n also honors an embedder's CoreBuilder::action_dir) instead of recomputing via\n resolve_action_dir(&action_dir_override), which ignored a directly-set\n action_dir. Regression test added.\n

shanu06e15a693b66
diff --git a/src/openhuman/sandbox/schemas.rs b/src/openhuman/sandbox/schemas.rs
index f5c8373c96..868c01700a 100644
--- a/src/openhuman/sandbox/schemas.rs
+++ b/src/openhuman/sandbox/schemas.rs
@@ -4,7 +4,6 @@ use serde_json::{Map, Value};
use crate::core::all::{ControllerFuture, RegisteredController};
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
-use crate::openhuman::config::resolve_action_dir;
use crate::openhuman::config::rpc as config_rpc;
use crate::rpc::RpcOutcome;
@@ -48,7 +47,13 @@ pub fn schemas(function: &str) -> ControllerSchema {
FieldSchema {
name: "backend",
ty: TypeSchema::String,
- comment: "Backend kind to check: 'docker', 'local', or 'none'.",
+ comment: "Sandbox MODE to resolve, not the backend that is \
+ reported: 'docker'/'local' both map to the sandboxed \
+ mode, 'none' to no sandbox. The ACTUAL backend is \
+ resolved from the loaded runtime config (`[runtime] \
+ kind`) plus `is_remote`, so it reflects what an agent \
+ session would really get — e.g. 'docker' on a \
+ native-config host reports the Local backend.",
required: false,
},
FieldSchema {
@@ -144,6 +149,15 @@ pub fn schemas(function: &str) -> ControllerSchema {
}
}
+/// `sandbox.status` — report the backend an agent session would actually get.
+///
+/// The `backend` param selects the sandbox MODE to resolve, not the backend to
+/// report: `"docker"`/`"local"` both mean "resolve the sandboxed mode" and
+/// `"none"` means "no sandbox". The concrete backend is then derived from the
+/// loaded runtime config (`[runtime] kind`) plus `is_remote` — never from the
+/// requested name — so `backend:"docker"` on a native-config host reports Local,
+/// matching what a real session on that host would run. Reporting the requested
+/// backend instead was the conflation fixed in #6081.
fn handle_status(params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let backend_str = params
@@ -221,11 +235,19 @@ fn handle_resolve_policy(params: Map<String, Value>) -> ControllerFuture {
}
};
- // Honor the env `OPENHUMAN_ACTION_DIR` > persisted `action_dir_override`
- // > default precedence, matching how acting tools resolve their root.
- let action_dir = resolve_action_dir(&config.action_dir_override);
- let policy =
- super::ops::resolve_sandbox_policy(mode, &action_dir, &config.runtime, is_remote);
+ // Use the already-resolved `config.action_dir`. The loader fully
+ // resolves this field on every path: `load_or_init` sets it from the
+ // env `OPENHUMAN_ACTION_DIR` > persisted `action_dir_override` > default
+ // precedence (`resolve_action_dir` + `apply_env_overrides`), and an
+ // embedder-supplied config carries whatever `CoreBuilder::action_dir(..)`
+ // set directly. Re-deriving it here from `action_dir_override` alone
+ // would silently ignore an embedder's programmatic `action_dir` (#6081).
+ let policy = super::ops::resolve_sandbox_policy(
+ mode,
+ &config.action_dir,
+ &config.runtime,
+ is_remote,
+ );
to_json(RpcOutcome::new(policy, vec![]))
})
}
diff --git a/src/openhuman/sandbox/schemas_tests.rs b/src/openhuman/sandbox/schemas_tests.rs
index b050130e29..32012292f5 100644
--- a/src/openhuman/sandbox/schemas_tests.rs
+++ b/src/openhuman/sandbox/schemas_tests.rs
@@ -129,6 +129,38 @@ async fn handle_status_honors_loaded_docker_runtime() {
);
}
+/// #6081 (F2) — `sandbox_resolve_policy` must use the loaded config's
+/// already-resolved `action_dir`, not recompute it from `action_dir_override`
+/// alone. An embedder sets `Config.action_dir` directly via
+/// `CoreBuilder::action_dir(..)` and leaves `action_dir_override` at `None`;
+/// `resolve_action_dir(&None)` would have ignored that and returned the default
+/// projects dir, so the resolved policy would have pointed the sandbox at the
+/// wrong root. This pins that the handler honors the embedder's programmatic
+/// `action_dir`.
+#[tokio::test]
+async fn handle_resolve_policy_uses_loaded_action_dir() {
+ let embedder_action_dir = std::path::PathBuf::from("/tmp/openhuman-6081-action-dir");
+ let mut config = crate::openhuman::config::Config::default();
+ // The embedder-shaped case: `action_dir` set directly, override untouched.
+ config.action_dir = embedder_action_dir.clone();
+ config.action_dir_override = None;
+ let ctx = scoped_ctx(config);
+
+ let mut params = Map::new();
+ params.insert("sandbox_mode".into(), Value::String("none".into()));
+
+ let val = CoreContext::scope(ctx, async { handle_resolve_policy(params).await })
+ .await
+ .expect("resolve_policy should succeed under the scoped config");
+
+ assert_eq!(
+ val.get("workspace_root").and_then(|w| w.as_str()),
+ Some(embedder_action_dir.to_str().unwrap()),
+ "policy workspace_root must use the loaded config.action_dir, not a \
+ recomputed default; got {val:?}"
+ );
+}
+
#[tokio::test]
async fn handle_validate_policy_valid() {
let policy = super::super::types::SandboxPolicy {