Skip to content

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

fix(shell): report the runtime's shell flavor in the tool description

Steven Enamakel3e11a0468d3d
diff --git a/crates/openhuman-core/src/agent/host_runtime.rs b/crates/openhuman-core/src/agent/host_runtime.rs
index 91667b94ef..bf77ba06a8 100644
--- a/crates/openhuman-core/src/agent/host_runtime.rs
+++ b/crates/openhuman-core/src/agent/host_runtime.rs
@@ -17,6 +17,12 @@ 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,
@@ -158,6 +164,12 @@ 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 556a17872b..1f1c11b124 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell.rs
@@ -2,7 +2,6 @@ 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};
@@ -169,7 +168,7 @@ impl Tool for ShellTool {
}
fn description(&self) -> &str {
- shell_description(ShellFlavor::current())
+ shell_description(self.runtime.shell_flavor())
}
fn parameters_schema(&self) -> serde_json::Value {
@@ -178,7 +177,7 @@ impl Tool for ShellTool {
"properties": {
"command": {
"type": "string",
- "description": command_param_description(ShellFlavor::current())
+ "description": command_param_description(self.runtime.shell_flavor())
},
"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 9734a6d911..a5a55e7d58 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,3 +155,62 @@ 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);
+}