Skip to content

PSReadline setup in Visual Studio terminal breaks agentic Copilot CLI functionality #4883

@KirkMunroSagent

Description

@KirkMunroSagent

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

N/A

Screenshot

I'm using agentic AI a lot more and currently working in Visual Studio 2022 (latest) with Copilot. When I ask Copilot to do something very simple, such as echo Hello World and verify that it can get the response, it fails to get the response.

The issue comes down to this command that gets run every time that I open the terminal in Visual Studio, or every time I ask Copilot to run a command in the terminal when it is closed:

if (Get-Module -Name PSReadLine) { $Global:DevEnvOriginalPSConsoleHostReadLine = $function:PSConsoleHostReadLine; function Global:PSConsoleHostReadLine { $CommandLine = $Global:DevEnvOriginalPSConsoleHostReadLine.Invoke(); [Console]::Write("$([char]0x1b)]633;C$([char]0x1b)\"); $CommandLine } }

If I undo that command, which so far I have only been able to do after the terminal opens, then CLI commands from agentic Copilot work. If I leave that command in place, then the agent fails to get results from commands that it tries to run in the terminal.

So, I'd like to know (if possible), where does this one-liner come from, why was it added, and can I disable it so that I can use Copilot to execute CLI commands in Visual Studio in agent mode without issue?

Environment data

PS Version: 7.5.2
PS HostName: ConsoleHost
PSReadLine Version: 2.3.6
PSReadLine EditMode: Windows
OS: 10.0.26100.1 (WinBuild.160101.0800)
BufferWidth: 343
BufferHeight: 26

Steps to reproduce

Try asking Copilot in Agent mode in Visual Studio to echo Hello World and confirm that it gets a response.

Expected behavior

It should get a response.

Actual behavior

It shows an error indicating that it failed to run the command.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions