-
-
Notifications
You must be signed in to change notification settings - Fork 69.6k
[Bug] Exec tool corrupts PowerShell pipeline variables on Windows - \ stripped, -f operator broken #35807
Description
Bug Report
Supersedes: #6443 (locked — not resolved. Confirmed by 2 independent users)
Expected behavior
Exec tool passes PowerShell commands to the shell verbatim. Pipeline variables and operators work as expected.
Observed behavior
Exec tool corrupts PowerShell commands on Windows when passed inline:
- \\ (pipeline variable) is stripped or mangled
- -f\ string format operator fails with parse errors
- \ForEach-Object, \Where-Object\ fail silently or produce wrong output
Commands work correctly when written to a .ps1 file and executed with \powershell -File.
Environment
- OpenClaw: v2026.2.26
- OS: Windows 10 x64 + confirmed Windows 11 (see [Feature] Exec tool: native PowerShell mode to bypass escaping issues #6443 comments)
- Shell: PowerShell 5.1 / 7.x
Root cause (suspected)
Exec tool routes through cmd.exe, which mangles \$, backticks, and double-quotes before PowerShell sees them.
Workaround
Write command to temp .ps1 file, execute with \powershell -File script.ps1, clean up. Required for every non-trivial inline PowerShell command. Adds 2-3 extra tool calls per operation.
Impact
At our current usage rate (~20 exec calls/hour), the workaround adds significant token overhead. Every Windows agent deployment is affected.