Skip to content

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

refactor(shell): extract python runtime logging into a helper function

Steven Enamakel11befeac92ca
diff --git a/crates/openhuman-core/src/runtime/python/bootstrap.rs b/crates/openhuman-core/src/runtime/python/bootstrap.rs
index 56c525afa0..9a16e0acde 100644
--- a/crates/openhuman-core/src/runtime/python/bootstrap.rs
+++ b/crates/openhuman-core/src/runtime/python/bootstrap.rs
@@ -92,6 +92,13 @@ impl PythonBootstrap {
}
}
+ #[cfg(test)]
+ pub(crate) fn cache_for_test(&self, resolved: ResolvedPython) {
+ if let Ok(mut cached) = self.cached.lock() {
+ *cached = Some(resolved);
+ }
+ }
+
/// The configuration this bootstrap resolves under.
#[must_use]
pub fn config(&self) -> &Config {
diff --git a/crates/openhuman-core/src/tools/impl/system/shell.rs b/crates/openhuman-core/src/tools/impl/system/shell.rs
index c2257d177d..ae0954f306 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell.rs
@@ -579,17 +579,10 @@ impl ShellTool {
prepend_dirs.push(resolved.bin_dir);
}
Err(error) => {
- if !bootstrap.config().runtime_python.enabled {
- tracing::debug!(
- error = %error,
- "[shell] python runtime disabled — running on the inherited PATH"
- );
- } else {
- tracing::warn!(
- error = %error,
- "[shell] python runtime unavailable — running on the inherited PATH"
- );
- }
+ log_python_runtime_unavailable(
+ bootstrap.config().runtime_python.enabled,
+ &error,
+ );
}
}
}
@@ -606,6 +599,20 @@ impl ShellTool {
}
}
+fn log_python_runtime_unavailable(enabled: bool, error: &anyhow::Error) {
+ if enabled {
+ tracing::warn!(
+ error = %error,
+ "[shell] python runtime unavailable — running on the inherited PATH"
+ );
+ } else {
+ tracing::debug!(
+ error = %error,
+ "[shell] python runtime disabled — running on the inherited PATH"
+ );
+ }
+}
+
fn prepend_path_dirs<'a>(
dirs: impl IntoIterator<Item = &'a std::path::Path>,
host_path: &str,