Skip to content

Allow Agents UI to fall back to Windows PowerShell when pwsh is unavailable#312999

Open
sheetsync wants to merge 2 commits intomicrosoft:mainfrom
sheetsync:fix/agents-windows-powershell-fallback
Open

Allow Agents UI to fall back to Windows PowerShell when pwsh is unavailable#312999
sheetsync wants to merge 2 commits intomicrosoft:mainfrom
sheetsync:fix/agents-windows-powershell-fallback

Conversation

@sheetsync
Copy link
Copy Markdown

@sheetsync sheetsync commented Apr 28, 2026

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 Sysnative path 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-client
  • npm run test-node -- --run src/vs/platform/agentHost/test/node/copilotShellTools.test.ts
  • npx eslint src/vs/platform/agentHost/node/copilot/copilotShellTools.ts src/vs/platform/agentHost/test/node/copilotShellTools.test.ts
  • git diff --check

Manual verification

Suggested Windows verification for reviewers:

  1. Confirm pwsh.exe is not available: where pwsh should find no executable.
  2. Confirm Windows PowerShell is available: where powershell should find %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe.
  3. Launch VS Code from this PR build.
  4. Start an Agents UI / Copilot CLI chat session that runs a shell tool.
  5. Confirm the shell tool starts successfully instead of failing with a missing pwsh.exe error.
  6. Confirm commands run through Windows PowerShell.

Copilot AI review requested due to automatic review settings April 28, 2026 10:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.exe and otherwise falls back to System32/Sysnative Windows 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.

Comment thread src/vs/platform/agentHost/node/copilot/copilotShellTools.ts Outdated
Comment thread src/vs/platform/agentHost/node/copilot/copilotShellTools.ts
Comment thread src/vs/platform/agentHost/node/copilot/copilotShellTools.ts Outdated
@sheetsync
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@sheetsync sheetsync force-pushed the fix/agents-windows-powershell-fallback branch from dc2ab47 to 3a410be Compare April 28, 2026 10:42
@sheetsync
Copy link
Copy Markdown
Author

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.

@sheetsync
Copy link
Copy Markdown
Author

This addresses issue #308584

@vscode-prebuilds-bot please link this PR to issue 308584

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Visual Studio Code Agents (Preview) should gracefully handle PowerShell shell fallback on Windows

3 participants