From 424557fedb658a8d02947ac9fe6365f440826434 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Wed, 8 Apr 2026 16:50:45 +0800 Subject: [PATCH] fix(win): use PowerShell instead of cmd.exe --- agent/tools/bash/bash.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/agent/tools/bash/bash.py b/agent/tools/bash/bash.py index 4c8523f5..5933d604 100644 --- a/agent/tools/bash/bash.py +++ b/agent/tools/bash/bash.py @@ -108,12 +108,13 @@ SAFETY: if self._IS_WIN: env["PYTHONIOENCODING"] = "utf-8" - # Use PowerShell so that LLM-generated commands can use - # Select-String, Select-Object, curl (Invoke-WebRequest alias), - # etc. instead of Unix-only head/grep/tail. + wrapped = ( + "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; " + f"{command}; exit $LASTEXITCODE" + ) result = subprocess.run( ["powershell.exe", "-NoProfile", "-NonInteractive", - "-ExecutionPolicy", "Bypass", "-Command", command], + "-ExecutionPolicy", "Bypass", "-Command", wrapped], cwd=self.cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,