Windows: Exec tool returns empty output unless pty: true
Work around a Windows regression where non-PTY exec produces no output or side effects by forcing PTY and (optionally) capturing clean output via a temp file.
Symptoms
- On Windows (10/11),
exectool calls withpty: false(or omitted) return empty output. - Even commands that should have side effects appear to do nothing:
echo test > file.txtdoes not createfile.txtWrite-Output testprints nothing
- The same commands work when
pty: true.
Cause
This is a known regression affecting the Windows non-PTY execution path in some OpenClaw versions. Using pty: true
routes execution through a different code path that continues to work.
Fix
1) Force PTY for all exec calls on Windows
When calling the exec tool, always include pty: true:
{ "command": "echo test", "pty": true }
2) If you need clean output, round-trip through a temp file
PTY mode can include ANSI escape sequences in the returned output. A simple workaround is to redirect output to a temp file and then read it back:
powershell -NoProfile -Command "echo test | Out-File -FilePath $env:TEMP\\exec.out -Encoding utf8; Get-Content $env:TEMP\\exec.out"
Verify
Run an exec call with pty: true:
echo test
You should see test in the tool output. If you use redirection, confirm the file actually exists and has content.