Skip to content

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

fix(shell): make runtime resolution failures non-fatal

Steven Enamakelb3acc3e77e57
diff --git a/crates/openhuman-core/src/tools/impl/system/shell.rs b/crates/openhuman-core/src/tools/impl/system/shell.rs
index 0d829fa40a..7fe1729269 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell.rs
@@ -399,18 +399,9 @@ impl ShellTool {
);
}
- match self.runtime_path_for_command(command).await {
- Ok(Some(path)) => {
- tracing::debug!(path = %path, "[shell] applying managed runtime PATH");
- cmd.env("PATH", path);
- }
- Ok(None) => {}
- Err(error) => {
- return (
- true,
- ToolResult::error(format!("Failed to resolve command runtime: {error}")),
- );
- }
+ if let Some(path) = self.runtime_path_for_command(command).await {
+ tracing::debug!(path = %path, "[shell] applying managed runtime PATH");
+ cmd.env("PATH", path);
}
// No default deadline — only a caller-supplied `timeout_secs` bounds the
@@ -490,17 +481,8 @@ impl ShellTool {
);
let mut extra_env = std::collections::HashMap::new();
- match self.runtime_path_for_command(command).await {
- Ok(Some(path)) => {
- extra_env.insert("PATH".into(), path.into());
- }
- Ok(None) => {}
- Err(error) => {
- return (
- true,
- ToolResult::error(format!("Failed to resolve command runtime: {error}")),
- );
- }
+ if let Some(path) = self.runtime_path_for_command(command).await {
+ extra_env.insert("PATH".into(), path.into());
}
// Apply the same Git config hardening to local and sandboxed shells.
@@ -555,7 +537,15 @@ impl ShellTool {
}
}
- async fn runtime_path_for_command(&self, command: &str) -> anyhow::Result<Option<String>> {
+ ///
+ /// A runtime that cannot be resolved (its module refused or faulted, the
+ /// download failed) leaves the inherited `PATH` in place rather than
+ /// failing the command: the host's own interpreter may well run it, and if
+ /// none exists the command fails with its own `command not found`. Failing
+ /// here instead blocked every `python …` command for the rest of the run
+ /// once the runtime module had faulted, even with a working `python3` on
+ /// the host.
+ async fn runtime_path_for_command(&self, command: &str) -> Option<String> {
let mut prepend_dirs = Vec::new();
// Node injection preserves the existing contract: shell only sees the
@@ -573,25 +563,34 @@ impl ShellTool {
if shell_command_needs_python_runtime(command) {
if let Some(bootstrap) = self.python_bootstrap.as_ref() {
- let resolved = bootstrap.resolve().await?;
- tracing::debug!(
- bin_dir = %resolved.bin_dir.display(),
- python_bin = %resolved.python_bin.display(),
- version = %resolved.version,
- source = ?resolved.source,
- "[shell] prepending python runtime bin to PATH"
- );
- prepend_dirs.push(resolved.bin_dir);
+ match bootstrap.resolve().await {
+ Ok(resolved) => {
+ tracing::debug!(
+ bin_dir = %resolved.bin_dir.display(),
+ python_bin = %resolved.python_bin.display(),
+ version = %resolved.version,
+ source = ?resolved.source,
+ "[shell] prepending python runtime bin to PATH"
+ );
+ prepend_dirs.push(resolved.bin_dir);
+ }
+ Err(error) => {
+ tracing::warn!(
+ error = %error,
+ "[shell] python runtime unavailable — running on the inherited PATH"
+ );
+ }
+ }
}
}
if prepend_dirs.is_empty() {
- Ok(None)
+ None
} else {
- Ok(Some(prepend_path_dirs(
+ Some(prepend_path_dirs(
prepend_dirs.iter().map(|p| p.as_path()),
&std::env::var("PATH").unwrap_or_default(),
- )))
+ ))
}
}
}
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 510112bb66..65c6951b89 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
@@ -72,10 +72,7 @@ async fn shell_does_not_resolve_or_install_node_on_its_own() {
// Unprimed (no prior node_exec/npm_exec resolve): shell injects NO
// managed node bin onto PATH — it does not auto-resolve or install.
- let injected = tool
- .runtime_path_for_command("node --version")
- .await
- .expect("runtime path resolves");
+ let injected = tool.runtime_path_for_command("node --version").await;
assert!(
injected.is_none(),
"shell injected a managed node bin without any prior node_exec/npm_exec \