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/tools/impl/system/shell_tests_runtime_and_sandbox_tes

Steven Enamakel92cdbe15abeb
diff --git a/crates/openhuman-core/src/tools/impl/system/shell_tests_runtime_and_sandbox_tests.rs b/crates/openhuman-core/src/tools/impl/system/shell_tests_runtime_and_sandbox_tests.rs
index 5d3e661a68..d609ca3406 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell_tests_runtime_and_sandbox_tests.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell_tests_runtime_and_sandbox_tests.rs
@@ -115,6 +115,64 @@ async fn shell_keeps_inherited_path_when_python_runtime_is_unavailable() {
);
}
+#[test]
+fn shell_runtime_failure_logging_accepts_enabled_and_disabled_runtime_states() {
+ log_python_runtime_unavailable(true, &anyhow::anyhow!("test resolution failure"));
+ log_python_runtime_unavailable(false, &anyhow::anyhow!("test disabled runtime"));
+}
+
+#[cfg(unix)]
+fn shell_with_cached_python() -> (ShellTool, tempfile::TempDir) {
+ use crate::runtime::python::{PythonSource, ResolvedPython};
+ use std::os::unix::fs::PermissionsExt;
+
+ let bin_dir = tempfile::tempdir().unwrap();
+ let python_bin = bin_dir.path().join("python3");
+ std::fs::write(&python_bin, "#!/bin/sh\necho managed-python-path\n").unwrap();
+ std::fs::set_permissions(&python_bin, std::fs::Permissions::from_mode(0o755)).unwrap();
+
+ let mut config = crate::config::Config::default();
+ config.runtime_python.enabled = true;
+ let python = Arc::new(PythonBootstrap::new(Arc::new(config)));
+ python.cache_for_test(ResolvedPython {
+ bin_dir: bin_dir.path().to_path_buf(),
+ python_bin,
+ version: "test".into(),
+ source: PythonSource::Managed,
+ });
+ (
+ ShellTool::with_language_bootstraps(
+ test_security(AutonomyLevel::Full),
+ test_runtime(),
+ test_audit(),
+ None,
+ Some(python),
+ ),
+ bin_dir,
+ )
+}
+
+#[cfg(unix)]
+#[tokio::test]
+async fn shell_uses_cached_python_path_in_native_mode() {
+ use crate::agent::harness::definition::SandboxMode;
+ use crate::agent::harness::with_current_sandbox_mode;
+
+ let (tool, _bin_dir) = shell_with_cached_python();
+ let result = with_current_sandbox_mode(SandboxMode::None, async {
+ tool.execute(json!({"command": "python3 -c 'print(1)'"}))
+ .await
+ .unwrap()
+ })
+ .await;
+ assert!(
+ !result.is_error,
+ "managed Python command failed: {}",
+ result.output()
+ );
+ assert!(result.output().contains("managed-python-path"));
+}
+
#[tokio::test]
async fn shell_blocks_rate_limited() {
let security = Arc::new(SecurityPolicy {
@@ -136,25 +194,21 @@ async fn shell_sandboxed_mode_routes_through_sandbox_backend() {
use crate::agent::harness::definition::SandboxMode;
use crate::agent::harness::with_current_sandbox_mode;
- let tool = ShellTool::new(
- test_security(AutonomyLevel::Supervised),
- test_runtime(),
- test_audit(),
- );
+ let (tool, _bin_dir) = shell_with_cached_python();
let result = with_current_sandbox_mode(SandboxMode::Sandboxed, async {
- tool.execute(json!({"command": "echo sandboxed-output"}))
+ tool.execute(json!({"command": "python3 -c 'print(1)'"}))
.await
.unwrap()
})
.await;
assert!(
!result.is_error,
- "sandboxed echo should succeed: {}",
+ "sandboxed managed Python command should succeed: {}",
result.output()
);
assert!(
- result.output().contains("sandboxed-output"),
- "expected 'sandboxed-output' in result, got: {:?}",
+ result.output().contains("managed-python-path"),
+ "expected managed Python PATH in result, got: {:?}",
result.output()
);
}