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
refactor(shell): delegate shell descriptions to TinyAgents ExecTool
Steven Enamakelb43583b26648
diff --git a/crates/openhuman-core/src/tools/impl/system/mod.rs b/crates/openhuman-core/src/tools/impl/system/mod.rsindex b2fd6ac8e0..dd7029c8c8 100644--- a/crates/openhuman-core/src/tools/impl/system/mod.rs+++ b/crates/openhuman-core/src/tools/impl/system/mod.rs@@ -9,7 +9,6 @@ mod proxy_config;mod retrieve_tool_output;mod schedule;mod shell;-mod shell_description;mod shell_saas;mod shell_support;mod update_apply;diff --git a/crates/openhuman-core/src/tools/impl/system/shell.rs b/crates/openhuman-core/src/tools/impl/system/shell.rsindex 1753fabd18..02bda9dc85 100644--- a/crates/openhuman-core/src/tools/impl/system/shell.rs+++ b/crates/openhuman-core/src/tools/impl/system/shell.rs@@ -1,4 +1,3 @@-use super::shell_description::{command_param_description, shell_description};#[cfg(feature = "modules")]use super::shell_support::container_environment;use super::shell_support::{command_failure, exec_result, python_utf8_env, tool_timeout_message};diff --git a/crates/openhuman-core/src/tools/impl/system/shell_description.rs b/crates/openhuman-core/src/tools/impl/system/shell_description.rsdeleted file mode 100644index b9ca9a54b0..0000000000--- a/crates/openhuman-core/src/tools/impl/system/shell_description.rs+++ /dev/null@@ -1,38 +0,0 @@-//! What the `shell` tool tells the model about the shell it runs.-//!-//! Which shell runs, and the environment it starts from, are TinyBox's-//! (`SelectShell` / `StartNativeShellExec`). This is only the model-facing text,-//! a pure function of the contract's [`ShellFlavor`] so both flavors are testable-//! on any host.--use crate::modules::tinybox::host_runtime::ShellFlavor;--/// The `shell` tool description for the shell this host spawns. Models default-/// to POSIX syntax, so on Windows the description says outright that commands-/// run under `cmd.exe` and gives the equivalents of the commands they reach for.-pub(super) fn shell_description(flavor: ShellFlavor) -> &'static str {- match flavor {- ShellFlavor::Cmd => {- "Execute a command under Windows cmd.exe (`cmd /C`), not a POSIX shell: run code, \- manipulate workspace files, or launch applications (`start \"\" music:`). Use cmd \- syntax: `cd` with no argument prints the current directory (no `pwd`), `dir` lists \- (no `ls`), `type` prints a file (no `cat`), `findstr` searches (no `grep`), \- `del`/`copy`/`move` replace rm/cp/mv, variables are `%VAR%` (not `$VAR`), and \- commands chain with `&&` (`;` is not a separator). For PowerShell run \- `powershell -NoProfile -Command \"...\"`. Only stdout/stderr comes back, so a script \- that computes silently or only writes a file returns nothing — print what you need, \- or read the file afterwards."- }- ShellFlavor::Posix => {- "Execute a shell command: run code, manipulate workspace files, or launch applications (`open -a Music`, `xdg-open music://`). Only stdout/stderr comes back, so a script that computes silently or only writes a file returns nothing — print what you need, or read the file afterwards."- }- }-}--/// The `command` parameter's description, matching [`shell_description`].-pub(super) fn command_param_description(flavor: ShellFlavor) -> &'static str {- match flavor {- ShellFlavor::Cmd => "The cmd.exe command to execute (cmd syntax, not POSIX)",- ShellFlavor::Posix => "The shell command to execute",- }-}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.rsindex 5a0f28a25f..8a029c3c64 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@@ -1,8 +1,5 @@-//! Platform-aware shell description (`shell_description.rs`) and the Python-//! encoding defaults, exercised through the `shell` tool.-//!-//! The description takes the platform as a parameter so the Windows wording is-//! pinned on every CI host, not only on a Windows runner.+//! Platform-aware shell metadata delegated to TinyAgents' `ExecTool`, plus the+//! Python encoding defaults used by OpenHuman's runtime adapter.use super::*;use crate::modules::tinybox::host_runtime::{host_shell_flavor, ShellFlavor};@@ -15,7 +12,13 @@ use std::ffi::OsString;fn windows_description_names_cmd_and_its_equivalents_of_posix_commands() {// Production (0.64.x): models sent `pwd; ls` and `cat` to cmd.exe because// the description read like a POSIX shell.- let desc = shell_description(ShellFlavor::Cmd);+ let desc = ShellTool::new(+ test_security(AutonomyLevel::Supervised),+ Arc::new(CmdRuntime),+ test_audit(),+ )+ .description()+ .to_owned();assert!(desc.contains("cmd.exe"), "{desc}");for equivalent in ["`cd`", "`dir`", "`type`", "`findstr`", "`%VAR%`", "`&&`"] {assert!(desc.contains(equivalent), "missing {equivalent}: {desc}");@@ -31,19 +34,31 @@ fn windows_description_names_cmd_and_its_equivalents_of_posix_commands() {#[test]fn posix_description_does_not_mention_cmd() {- let desc = shell_description(ShellFlavor::Posix);+ let desc = ShellTool::new(+ test_security(AutonomyLevel::Supervised),+ test_runtime(),+ test_audit(),+ )+ .description()+ .to_owned();assert!(!desc.contains("cmd.exe"), "{desc}");assert!(desc.contains("print what you need"), "{desc}");}#[test]fn every_description_keeps_the_stdout_only_warning() {- for flavor in [ShellFlavor::Cmd, ShellFlavor::Posix] {- assert!(- shell_description(flavor).contains("Only stdout/stderr comes back"),- "{flavor:?}"- );- }+ let posix = ShellTool::new(+ test_security(AutonomyLevel::Supervised),+ test_runtime(),+ test_audit(),+ );+ let cmd = ShellTool::new(+ test_security(AutonomyLevel::Supervised),+ Arc::new(CmdRuntime),+ test_audit(),+ );+ assert!(posix.description().contains("Only stdout/stderr comes back"));+ assert!(cmd.description().contains("Only stdout/stderr comes back"));}#[test]@@ -53,13 +68,15 @@ fn the_tool_describes_the_shell_this_host_actually_spawns() {test_runtime(),test_audit(),);- assert_eq!(tool.description(), shell_description(host_shell_flavor()));+ assert_eq!(+ tool.description().contains("cmd.exe"),+ host_shell_flavor() == ShellFlavor::Cmd+ );let command_desc = tool.parameters_schema()["properties"]["command"]["description"].as_str().unwrap().to_string();- assert_eq!(command_desc, command_param_description(host_shell_flavor()));- assert!(command_param_description(ShellFlavor::Cmd).contains("cmd.exe"));+ assert!(command_desc.contains("command"));}fn parent(vars: &[(&str, &str)]) -> impl Fn(&str) -> Option<OsString> {@@ -199,11 +216,11 @@ fn the_tool_describes_the_shell_its_runtime_spawns() {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)- );+ assert!(cmd_tool.description().contains("cmd.exe"));+ assert!(cmd_tool.parameters_schema()["properties"]["command"]["description"]+ .as_str()+ .unwrap()+ .contains("cmd.exe"));}#[test]