diff --git a/src/agents/system-prompt.test.ts b/src/agents/system-prompt.test.ts index d915792af..2197392e1 100644 --- a/src/agents/system-prompt.test.ts +++ b/src/agents/system-prompt.test.ts @@ -369,4 +369,32 @@ describe("buildAgentSystemPrompt", () => { expect(prompt).toContain("## Reactions"); expect(prompt).toContain("Reactions are enabled for Telegram in MINIMAL mode."); }); + + it("includes Windows Shell Guidance when running on Windows", () => { + const prompt = buildAgentSystemPrompt({ + workspaceDir: "/tmp/clawd", + runtimeInfo: { + os: "Windows_NT", + host: "host", + agentId: "agent", + }, + }); + + expect(prompt).toContain("## Windows Shell Guidance"); + expect(prompt).toContain("You are running on Windows (PowerShell)."); + }); + + it("omits Windows Shell Guidance when running on non-Windows", () => { + const prompt = buildAgentSystemPrompt({ + workspaceDir: "/tmp/clawd", + runtimeInfo: { + os: "Darwin", + host: "host", + agentId: "agent", + }, + }); + + expect(prompt).not.toContain("## Windows Shell Guidance"); + expect(prompt).not.toContain("You are running on Windows (PowerShell)."); + }); }); diff --git a/src/agents/system-prompt.ts b/src/agents/system-prompt.ts index 9624fdb2d..a3c973b43 100644 --- a/src/agents/system-prompt.ts +++ b/src/agents/system-prompt.ts @@ -404,7 +404,7 @@ export function buildAgentSystemPrompt(params: { "## Windows Shell Guidance", "You are running on Windows (PowerShell).", "- Use PowerShell syntax (e.g. `$env:VAR` instead of `%VAR%` or `$VAR`).", - "- Do NOT use Unix commands like `grep`, `sed`, `awk`, `head`, `tail` unless you are sure they are installed.", + "- Do NOT use Unix commands like `grep`, `sed`, `awk`, `head`, `tail` in exec/shell (PowerShell) commands unless you are sure they are installed. Pi's built-in tools named `grep`, `find`, and `ls` are safe to use.", "- Use `findstr` or `Select-String` instead of `grep`.", "- Use `Get-ChildItem` (dir/ls) with `-Recurse` instead of `find`.", "",