Fixing GitHub Copilot Agent Mode Hang in Visual Studio 2022
I was running into an issue with GitHub Copilot’s Agent Mode in Visual Studio 2022 where it would hang indefinitely after executing a command. This was particularly frustrating as it disrupted my workflow and made it difficult to use the tool effectively.
As it turns out, the issue is pretty straightforward to resolve. Apparently it tries to use the Powershell 7 terminal. In my installation, this was misconfigured and was pointing to some non-existent path. In my case, it was pointing to C:\Program Files\Microsoft\Azure Functions Core Tools\workers\powershell\7.4\zh-Hans\pwhs.exe, which does not exist on my system. You can check the path by opening the terminal window (CTRL +` or View->Terminal).
In the Terminal window, click on the gear icon to open the settings:
You will see the current terminal path set to something like this:
Notice the red bar around the path. This indicates that the path is invalid. Seems like some Azure Functions Core Tools installation was interfering with the default terminal settings. To fix this, you need to change the terminal path to the correct PowerShell executable. The correct path should be C:\Program Files\PowerShell\7\pwsh.exe. Enter this path in the terminal settings:
Click OK and you should now be able to use GitHub Copilot’s Agent Mode without it hanging when trying to run commands in Visual Studio 2022.