Skip to content

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

refactor(shell): derive shell description from host instead of runtime

Steven Enamakelab28a59a155f
diff --git a/crates/openhuman-core/src/agent/host_runtime.rs b/crates/openhuman-core/src/agent/host_runtime.rs
index bf77ba06a8..91667b94ef 100644
--- a/crates/openhuman-core/src/agent/host_runtime.rs
+++ b/crates/openhuman-core/src/agent/host_runtime.rs
@@ -17,12 +17,6 @@ pub trait RuntimeAdapter: Send + Sync {
fn memory_budget(&self) -> u64 {
0
}
- /// The shell family [`Self::build_shell_command`] runs commands under, so
- /// what the `shell` tool tells the model matches what actually executes.
- /// Defaults to the host's own shell.
- fn shell_flavor(&self) -> platform_shell::ShellFlavor {
- platform_shell::ShellFlavor::current()
- }
fn build_shell_command(
&self,
command: &str,
@@ -164,12 +158,6 @@ impl RuntimeAdapter for DockerRuntime {
self.config.memory_limit_mb.unwrap_or(0)
}
- /// Commands run under `sh -lc` inside the container on every host,
- /// including Windows, so the model must be told POSIX, not cmd.exe.
- fn shell_flavor(&self) -> platform_shell::ShellFlavor {
- platform_shell::ShellFlavor::Posix
- }
-
fn build_shell_command(
&self,
command: &str,
diff --git a/crates/openhuman-core/src/tools/impl/system/shell.rs b/crates/openhuman-core/src/tools/impl/system/shell.rs
index 1f1c11b124..556a17872b 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell.rs
@@ -2,6 +2,7 @@ use super::shell_platform::{
command_param_description, python_utf8_env, shell_child_env, shell_description,
};
use crate::agent::host_runtime::RuntimeAdapter;
+use crate::agent::platform_shell::ShellFlavor;
use crate::runtime::javascript::NodeBootstrap;
use crate::runtime::python::PythonBootstrap;
use crate::security::{AuditLogger, CommandExecutionLog, GateDecision, SecurityPolicy};
@@ -168,7 +169,7 @@ impl Tool for ShellTool {
}
fn description(&self) -> &str {
- shell_description(self.runtime.shell_flavor())
+ shell_description(ShellFlavor::current())
}
fn parameters_schema(&self) -> serde_json::Value {
@@ -177,7 +178,7 @@ impl Tool for ShellTool {
"properties": {
"command": {
"type": "string",
- "description": command_param_description(self.runtime.shell_flavor())
+ "description": command_param_description(ShellFlavor::current())
},
"category": {
"type": "string",
diff --git a/crates/openhuman-core/src/tools/impl/system/shell_tests_platform_tests.rs b/crates/openhuman-core/src/tools/impl/system/shell_tests_platform_tests.rs
index a5a55e7d58..9734a6d911 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell_tests_platform_tests.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell_tests_platform_tests.rs
@@ -155,62 +155,3 @@ async fn a_spawned_shell_sees_the_python_utf8_defaults() {
assert!(!result.is_error, "{}", result.output());
assert_eq!(result.output().trim(), expected);
}
-
-/// A runtime that spawns cmd.exe regardless of the host, so the description
-/// is provably taken from the runtime rather than from `cfg!(windows)`.
-struct CmdRuntime;
-
-impl RuntimeAdapter for CmdRuntime {
- fn name(&self) -> &str {
- "cmd-test"
- }
- fn has_shell_access(&self) -> bool {
- true
- }
- fn has_filesystem_access(&self) -> bool {
- true
- }
- fn storage_path(&self) -> std::path::PathBuf {
- std::env::temp_dir()
- }
- fn supports_long_running(&self) -> bool {
- true
- }
- fn shell_flavor(&self) -> ShellFlavor {
- ShellFlavor::Cmd
- }
- fn build_shell_command(
- &self,
- _command: &str,
- _workspace_dir: &std::path::Path,
- ) -> anyhow::Result<tokio::process::Command> {
- anyhow::bail!("not spawned in this test")
- }
-}
-
-#[test]
-fn the_tool_describes_the_shell_its_runtime_spawns() {
- let cmd_tool = ShellTool::new(
- test_security(AutonomyLevel::Supervised),
- Arc::new(CmdRuntime),
- test_audit(),
- );
- assert_eq!(cmd_tool.description(), shell_description(ShellFlavor::Cmd));
- assert_eq!(
- cmd_tool.parameters_schema()["properties"]["command"]["description"],
- command_param_description(ShellFlavor::Cmd)
- );
-}
-
-#[test]
-fn the_docker_runtime_always_runs_posix_sh() {
- let docker = crate::agent::host_runtime::create_runtime(
- &crate::config::RuntimeConfig {
- kind: "docker".into(),
- ..crate::config::RuntimeConfig::default()
- },
- false,
- )
- .expect("docker runtime");
- assert_eq!(docker.shell_flavor(), ShellFlavor::Posix);
-}