Allow Agents UI to fall back to Windows PowerShell when pwsh is unavailable#312999
Allow Agents UI to fall back to Windows PowerShell when pwsh is unavailable#312999sheetsync wants to merge 2 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the agent-host shell resolution on Windows so Agents UI / Copilot CLI shell tools can prefer PowerShell Core (pwsh) and fall back to Windows PowerShell when needed, aligning more closely with VS Code terminal behavior and ensuring command guidance remains compatible.
Changes:
- Add an async shell executable resolver that checks for
pwsh.exeand otherwise falls back toSystem32/SysnativeWindows PowerShell. - Update ShellManager to use the resolved shell executable when creating terminals.
- Expand unit tests to cover Windows PowerShell fallback and Sysnative behavior; adjust PowerShell tool guidance to avoid
&&.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/vs/platform/agentHost/node/copilot/copilotShellTools.ts | Adds async Windows PowerShell resolution (pwsh → WinPS fallback), updates terminal creation to use it, and adjusts WinPS detection + model guidance text. |
| src/vs/platform/agentHost/test/node/copilotShellTools.test.ts | Adds targeted tests for the new PowerShell resolution behavior across Windows/non-Windows scenarios. |
|
@microsoft-github-policy-service agree |
dc2ab47 to
3a410be
Compare
|
Hi, guys at VSCode. Actual human who needs this change here. I committed this because it's been a point of frustration for us. The machines we develop on are - by company policy - locked down and do not have modern Powershell. This is partly because we operate in a heavily regulated industry. The VSCode copilot agents can easily use Windows Powershell, but the new VSCode Agents app does not have this behaviour. Although I'll find this useful at work, I'm submitting this change as a private individual and not on behalf of my employer. I have used my personal computer and time to make the change. |
|
This addresses issue #308584 @vscode-prebuilds-bot please link this PR to issue 308584 |
Summary
Allow the Agents UI / Copilot CLI shell tools on Windows to prefer PowerShell Core (
pwsh.exe) when available and fall back to Windows PowerShell when it is not.VS Code's integrated terminal already accounts for Windows PowerShell, including the
Sysnativepath needed by 32-bit processes on 64-bit Windows. This change applies the same shape of fallback to the agent-host shell resolver while preserving existing non-Windows behavior.The PowerShell tool guidance now avoids
&&so commands remain compatible when the agent falls back to Windows PowerShell 5.1.Fixes #308584
Related context: github/copilot-cli#411
Testing
NODE_OPTIONS=--max-old-space-size=8192 node ./node_modules/gulp/bin/gulp.js compile-clientnpm run test-node -- --run src/vs/platform/agentHost/test/node/copilotShellTools.test.tsnpx eslint src/vs/platform/agentHost/node/copilot/copilotShellTools.ts src/vs/platform/agentHost/test/node/copilotShellTools.test.tsgit diff --checkManual verification
Suggested Windows verification for reviewers:
pwsh.exeis not available:where pwshshould find no executable.where powershellshould find%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe.pwsh.exeerror.