diff --git a/codex-rs/core/src/tools/runtimes/unified_exec.rs b/codex-rs/core/src/tools/runtimes/unified_exec.rs index 86b6163b8..fd12607c1 100644 --- a/codex-rs/core/src/tools/runtimes/unified_exec.rs +++ b/codex-rs/core/src/tools/runtimes/unified_exec.rs @@ -202,13 +202,22 @@ impl<'a> ToolRuntime for UnifiedExecRunt ) -> Result { let base_command = &req.command; let session_shell = ctx.session.user_shell(); - let command = maybe_wrap_shell_lc_with_snapshot( - base_command, - session_shell.as_ref(), - &req.cwd, - &req.explicit_env_overrides, - &req.env, - ); + let environment_is_remote = ctx + .turn + .environment + .as_ref() + .is_some_and(|environment| environment.is_remote()); + let command = if environment_is_remote { + base_command.to_vec() + } else { + maybe_wrap_shell_lc_with_snapshot( + base_command, + session_shell.as_ref(), + &req.cwd, + &req.explicit_env_overrides, + &req.env, + ) + }; let command = if matches!(session_shell.shell_type, ShellType::PowerShell) { prefix_powershell_script_with_utf8(&command) } else {