Skip to content

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

refactor(shell): extract explicit environment merge into helper

Steven Enamakel6555a3962141
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs
index e7d2c39db1..261b56e901 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs
@@ -30,9 +30,7 @@ impl std::fmt::Debug for OpenHumanRunExt {
}
impl OpenHumanRunExt {
- pub(super) fn from_run_context(
- context: &super::run_context::OpenHumanRunContext,
- ) -> Self {
+ pub(super) fn from_run_context(context: &super::run_context::OpenHumanRunContext) -> Self {
Self {
task_recency_window: context.task_recency_window,
command_environment: context.command_environment.clone(),
diff --git a/crates/openhuman-core/src/tools/impl/system/shell.rs b/crates/openhuman-core/src/tools/impl/system/shell.rs
index b676c12e93..6549bf44c4 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell.rs
@@ -702,14 +702,10 @@ impl ShellTool {
let mut extra_env =
std::collections::HashMap::<std::ffi::OsString, std::ffi::OsString>::new();
let command_environment = command_environment_for_tool(context);
- if let Some(overrides) = command_environment.as_deref() {
- extra_env.extend(overrides.iter().map(|(name, value)| {
- (
- std::ffi::OsString::from(name),
- std::ffi::OsString::from(value),
- )
- }));
- }
+ super::shell_support::extend_explicit_environment(
+ &mut extra_env,
+ command_environment.as_deref(),
+ );
// Apply the same Git config hardening to local and sandboxed shells.
extra_env.extend(tinytools_std::filesystem::shell_git_env());
// And the same Python UTF-8 defaults the native path sets.
diff --git a/crates/openhuman-core/src/tools/impl/system/shell_support.rs b/crates/openhuman-core/src/tools/impl/system/shell_support.rs
index 699a12c1e9..4217b08b76 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell_support.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell_support.rs
@@ -115,3 +115,18 @@ pub(super) fn container_environment(
}
Some(env)
}
+
+/// Add the explicit turn environment to a sandbox command request.
+pub(super) fn extend_explicit_environment(
+ environment: &mut std::collections::HashMap<std::ffi::OsString, std::ffi::OsString>,
+ explicit: Option<&std::collections::BTreeMap<String, String>>,
+) {
+ if let Some(explicit) = explicit {
+ environment.extend(explicit.iter().map(|(name, value)| {
+ (
+ std::ffi::OsString::from(name),
+ std::ffi::OsString::from(value),
+ )
+ }));
+ }
+}