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
test(system): cover install backend environment passing
Steven Enamakel6a6c7e5fd1bf
diff --git a/crates/openhuman-core/src/tools/impl/system/install_tool_tests.rs b/crates/openhuman-core/src/tools/impl/system/install_tool_tests.rsindex 52de65bbd7..f754187ded 100644--- a/crates/openhuman-core/src/tools/impl/system/install_tool_tests.rs+++ b/crates/openhuman-core/src/tools/impl/system/install_tool_tests.rs@@ -2,6 +2,39 @@ use super::*;use crate::security::approval::ApprovalChatContext;use crate::security::AutonomyLevel;use serde_json::json;+use std::collections::BTreeMap;+use std::ffi::OsString;+use std::sync::Mutex;+use tinyagents_harness_tools::exec::{+ ExecBackendOutcome, ExecOutput, ExecProgress, ExecRequest, ShellFlavor,+};++#[derive(Default)]+struct RecordingBackend {+ environment: Mutex<Option<BTreeMap<OsString, OsString>>>,+}++#[async_trait::async_trait]+impl ExecBackend for RecordingBackend {+ fn shell_flavor(&self) -> ShellFlavor {+ ShellFlavor::Posix+ }++ async fn execute(+ &self,+ request: ExecRequest,+ _context: Option<&dyn tinytools::ToolRunContext>,+ _progress: Option<ExecProgress>,+ ) -> ExecBackendOutcome {+ *self.environment.lock().unwrap() = Some(request.environment);+ ExecBackendOutcome::Completed(ExecOutput {+ stdout: Vec::new(),+ stderr: Vec::new(),+ exit_code: Some(0),+ timed_out: false,+ })+ }+}fn policy(allow_install: bool, autonomy: AutonomyLevel) -> Arc<SecurityPolicy> {Arc::new(SecurityPolicy {@@ -104,3 +137,35 @@ async fn rejects_unknown_manager() {.unwrap();assert!(result.is_error);}++#[tokio::test]+async fn install_backend_receives_only_the_explicit_install_environment() {+ let expected = BTreeMap::from([+ (OsString::from("PATH"), OsString::from("/toolchain/bin")),+ (OsString::from("HOME"), OsString::from("/home/operator")),+ (OsString::from("CARGO_HOME"), OsString::from("/home/operator/.cargo")),+ ]);+ let backend = Arc::new(RecordingBackend::default());+ let tool = InstallToolTool::with_backend_and_environment(+ policy(true, AutonomyLevel::Full),+ AuditLogger::disabled(),+ backend.clone(),+ expected.clone(),+ );++ let result = tool+ .execute_with_context(+ json!({ "package": "fixture-package", "manager": "cargo" }),+ tinytools::ToolCallOptions::default(),+ Some(&chat_tool_context(chat_ctx())),+ )+ .await+ .unwrap();++ assert!(!result.is_error, "{}", result.output());+ assert_eq!(+ backend.environment.lock().unwrap().as_ref(),+ Some(&expected),+ "the installer backend must receive the host-approved environment"+ );+}