The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(sandbox): resolve policy/status from the loaded config, not defaults\n\nsandbox_resolve_policy and sandbox_status built RuntimeConfig::default() and\nnever loaded the user's config, so a user with [runtime] kind = "docker" was\ntold backend "local", docker_overrides were always the compiled-in defaults,\nand workspace_root was /tmp or the default action dir. handle_status also\nconflated is_remote with the caller-supplied backend name.\n\nLoad the live config via load_config_with_timeout() (the established sibling\npattern), pass &config.runtime and the resolved action/workspace dir into\nresolve_sandbox_policy, and read is_remote as an explicit optional param on\nstatus (documented in the schema). Add regression tests via a test-only\nembedder-config seam.\n\nFixes #6081\n
shanu723e37da675f
diff --git a/src/core/runtime/context.rs b/src/core/runtime/context.rsindex 1b2e312d2a..40725ea0ab 100644--- a/src/core/runtime/context.rs+++ b/src/core/runtime/context.rs@@ -522,6 +522,33 @@ impl CoreContext {embedder_config: None,})}++ /// Test-only constructor that carries an embedder-supplied config, so a+ /// cross-module test can exercise the `load_config_with_timeout()` read+ /// path (which prefers [`CoreContext::current_embedder_config`]) without a+ /// full boot or a racy on-disk `config.toml`.+ ///+ /// Distinct from [`CoreContext::for_test`] — which always sets+ /// `embedder_config: None` — so the ~30 existing `for_test` call sites are+ /// unaffected. The workspace binding is anchored to the config's+ /// `workspace_dir`, matching how [`CoreContext::init`] wires an+ /// embedder-supplied config.+ #[cfg(test)]+ pub(crate) fn for_test_with_config(+ domains: crate::core::runtime::DomainSet,+ config: crate::openhuman::config::Config,+ ) -> Arc<CoreContext> {+ Arc::new(CoreContext {+ host_kind: HostKind::Cli,+ workspace_binding: RwLock::new(WorkspaceBinding {+ workspace_dir: Some(config.workspace_dir.clone()),+ memory_subsystem: Default::default(),+ }),+ domains,+ tool_groups: Default::default(),+ embedder_config: Some(config),+ })+ }}/// Bind the memory driver for this workspace and initialize the otherdiff --git a/src/openhuman/sandbox/schemas.rs b/src/openhuman/sandbox/schemas.rsindex 029ce816ca..f5c8373c96 100644--- a/src/openhuman/sandbox/schemas.rs+++ b/src/openhuman/sandbox/schemas.rs@@ -4,6 +4,8 @@ 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;pub fn all_controller_schemas() -> Vec<ControllerSchema> {@@ -42,12 +44,22 @@ pub fn schemas(function: &str) -> ControllerSchema {namespace: "sandbox",function: "status",description: "Return sandbox backend status and availability.",- inputs: vec![FieldSchema {- name: "backend",- ty: TypeSchema::String,- comment: "Backend kind to check: 'docker', 'local', or 'none'.",- required: false,- }],+ inputs: vec![+ FieldSchema {+ name: "backend",+ ty: TypeSchema::String,+ comment: "Backend kind to check: 'docker', 'local', or 'none'.",+ required: false,+ },+ FieldSchema {+ name: "is_remote",+ ty: TypeSchema::Bool,+ comment: "Whether this is a remote/channel session. When true, a \+ sandboxed session resolves to the Docker backend even if \+ the runtime is not configured for Docker. Defaults to false.",+ required: false,+ },+ ],outputs: vec![FieldSchema {name: "status",ty: TypeSchema::Json,@@ -138,6 +150,15 @@ fn handle_status(params: Map<String, Value>) -> ControllerFuture {.get("backend").and_then(|v| v.as_str()).unwrap_or("none");+ // `is_remote` is an explicit caller-supplied flag, matching+ // `handle_resolve_policy`. It must NOT be inferred from `backend_str`:+ // naming the docker backend to check its availability is not the same+ // as running a remote/channel session, and conflating the two forced+ // Docker resolution for a local status probe (#6081).+ let is_remote = params+ .get("is_remote")+ .and_then(|v| v.as_bool())+ .unwrap_or(false);let mode = match backend_str {"docker" | "local" => {@@ -146,12 +167,23 @@ fn handle_status(params: Map<String, Value>) -> ControllerFuture {_ => crate::openhuman::agent::harness::definition::SandboxMode::None,};- let config = crate::openhuman::config::RuntimeConfig::default();- let is_remote = backend_str == "docker";+ // Load the user's live config so the reported policy reflects the+ // configured runtime (`[runtime] kind` + `[runtime.docker]` overrides)+ // and the mounted workspace, not the compiled-in `RuntimeConfig::default()`+ // (#6081). A failed config load surfaces to the caller rather than+ // silently answering from defaults.+ let config = match config_rpc::load_config_with_timeout().await {+ Ok(config) => config,+ Err(err) => {+ log::warn!("[sandbox] handle_status config load failed error={err}");+ return Err(err);+ }+ };+let policy = super::ops::resolve_sandbox_policy(mode,- std::path::Path::new("/tmp"),- &config,+ &config.workspace_dir,+ &config.runtime,is_remote,);let handle = super::ops::create_sandbox_backend(&policy).await;@@ -176,9 +208,24 @@ fn handle_resolve_policy(params: Map<String, Value>) -> ControllerFuture {_ => crate::openhuman::agent::harness::definition::SandboxMode::None,};- let config = crate::openhuman::config::RuntimeConfig::default();- let action_dir = crate::openhuman::config::default_action_dir();- let policy = super::ops::resolve_sandbox_policy(mode, &action_dir, &config, is_remote);+ // Load the user's live config so the resolved policy honors the+ // configured runtime (`[runtime] kind` + `[runtime.docker]` overrides)+ // and the user's action dir, not the compiled-in `RuntimeConfig::default()`+ // and `default_action_dir()` (#6081). A failed config load surfaces to+ // the caller rather than silently answering from defaults.+ let config = match config_rpc::load_config_with_timeout().await {+ Ok(config) => config,+ Err(err) => {+ log::warn!("[sandbox] handle_resolve_policy config load failed error={err}");+ return Err(err);+ }+ };++ // 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);to_json(RpcOutcome::new(policy, vec![]))})}diff --git a/src/openhuman/sandbox/schemas_tests.rs b/src/openhuman/sandbox/schemas_tests.rsindex dba5284f30..03277708a1 100644--- a/src/openhuman/sandbox/schemas_tests.rs+++ b/src/openhuman/sandbox/schemas_tests.rs@@ -43,6 +43,87 @@ async fn handle_resolve_policy_sandboxed_remote() {assert_eq!(backend, Some("docker"));}+/// Build a `Config` carrying a Docker runtime with a NON-default image, so a+/// test can prove the RPC handlers read the loaded runtime rather than+/// `RuntimeConfig::default()` (#6081).+#[cfg(test)]+fn docker_runtime_config() -> crate::openhuman::config::Config {+ let mut config = crate::openhuman::config::Config::default();+ config.workspace_dir = std::path::PathBuf::from("/tmp/openhuman-6081-ws");+ config.runtime.kind = "docker".into();+ config.runtime.docker.image = "ghcr.io/example/custom-sandbox:6081".into();+ config+}++/// #6081 regression — `sandbox_resolve_policy` must honor the loaded+/// `[runtime] kind = "docker"` config. Before the fix the handler answered from+/// `RuntimeConfig::default()` (`kind = "native"`), so a Docker-configured user+/// was told `backend = "local"`. The config is injected through the+/// embedder-config seam that `load_config_with_timeout()` reads, scoped for the+/// duration of the dispatch.+#[tokio::test]+async fn handle_resolve_policy_honors_loaded_docker_runtime() {+ use crate::core::runtime::context::CoreContext;+ use crate::core::runtime::DomainSet;++ let ctx = CoreContext::for_test_with_config(DomainSet::full(), docker_runtime_config());++ let mut params = Map::new();+ params.insert("sandbox_mode".into(), Value::String("sandboxed".into()));+ params.insert("is_remote".into(), Value::Bool(false));++ let val = CoreContext::scope(ctx, async { handle_resolve_policy(params).await })+ .await+ .expect("resolve_policy should succeed under the scoped config");++ // Consequence #1: the backend follows `[runtime] kind`, not the default.+ assert_eq!(+ val.get("backend").and_then(|b| b.as_str()),+ Some("docker"),+ "docker runtime must resolve to the docker backend; got {val:?}"+ );++ // Consequence #2: docker overrides reflect the user's `[runtime.docker]`,+ // not the compiled-in default image.+ let image = val+ .get("docker_overrides")+ .and_then(|o| o.get("image"))+ .and_then(|i| i.as_str());+ assert_eq!(+ image,+ Some("ghcr.io/example/custom-sandbox:6081"),+ "docker_overrides.image must reflect the loaded [runtime.docker].image; got {val:?}"+ );+}++/// #6081 regression — `sandbox_status` must likewise read the loaded runtime.+/// With `[runtime] kind = "docker"` and `is_remote = false`, a sandboxed status+/// probe resolves the docker backend; before the fix it answered "local" from+/// `RuntimeConfig::default()`. Uses `backend = "local"` in the request to prove+/// the resolution comes from the loaded config's `kind`, not the caller's+/// backend name.+#[tokio::test]+async fn handle_status_honors_loaded_docker_runtime() {+ use crate::core::runtime::context::CoreContext;+ use crate::core::runtime::DomainSet;++ let ctx = CoreContext::for_test_with_config(DomainSet::full(), docker_runtime_config());++ let mut params = Map::new();+ params.insert("backend".into(), Value::String("local".into()));+ params.insert("is_remote".into(), Value::Bool(false));++ let val = CoreContext::scope(ctx, async { handle_status(params).await })+ .await+ .expect("status should succeed under the scoped config");++ assert_eq!(+ val.get("kind").and_then(|k| k.as_str()),+ Some("docker"),+ "docker runtime must make status report the docker backend; got {val:?}"+ );+}+#[tokio::test]async fn handle_validate_policy_valid() {let policy = super::super::types::SandboxPolicy {