Describe the bug
Copilot CLI Feedback: PowerShell Process Leak on Windows
Issue
Copilot CLI does not clean up winpty-agent and pwsh processes after tool execution on Windows, causing significant memory accumulation over time.
Environment
- OS: Windows 11
- Shell: PowerShell 7 (pwsh)
- Copilot CLI: latest version
- Terminal: Windows Terminal
Observed Behavior
When Copilot CLI executes the powershell tool, it spawns a winpty-agent → pwsh process pair for each invocation. After the tool execution completes, neither process is terminated. Over a single session, dozens of orphan processes accumulate.
Example (observed data from a single work session):
| Copilot Session |
Duration |
Orphan pwsh |
Orphan winpty-agent |
Wasted Memory |
| Session 1 (oldest) |
~3 hours |
44 |
44 |
~3,500 MB |
| Session 2 |
~30 min |
2 |
2 |
~200 MB |
| Session 3 |
~20 min |
4 |
4 |
~300 MB |
| Total |
|
50 |
50 |
~4,000 MB |
Each orphan pwsh process consumes ~75 MB of memory and is completely idle (average CPU: 9 seconds total over 3 hours of uptime — only startup initialization).
Impact
- Memory: 50 orphan processes × ~75 MB = ~4 GB wasted RAM
- Process table: 100+ unnecessary processes (pwsh + winpty-agent)
- User confusion: Resource monitoring tools show alarming process counts
Workaround
Manual cleanup of orphan processes by terminating pwsh processes whose parent is a winpty-agent spawned by a copilot process.
Affected version
0.0.406
Steps to reproduce the behavior
- Start Copilot CLI on Windows (
copilot)
- Execute several prompts that trigger the
powershell tool
- Check process tree:
Get-Process -Name pwsh | Select Id, @{N='Parent';E={$_.Parent.Id}}
- Observe that each tool execution leaves behind a
winpty-agent → pwsh pair
Expected behavior
Copilot CLI should terminate winpty-agent and pwsh processes after the associated shell session/tool execution is complete, or at minimum reuse existing shell sessions instead of spawning new ones for each tool call.
Additional context
No response
Describe the bug
Copilot CLI Feedback: PowerShell Process Leak on Windows
Issue
Copilot CLI does not clean up
winpty-agentandpwshprocesses after tool execution on Windows, causing significant memory accumulation over time.Environment
Observed Behavior
When Copilot CLI executes the
powershelltool, it spawns awinpty-agent → pwshprocess pair for each invocation. After the tool execution completes, neither process is terminated. Over a single session, dozens of orphan processes accumulate.Example (observed data from a single work session):
Each orphan
pwshprocess consumes ~75 MB of memory and is completely idle (average CPU: 9 seconds total over 3 hours of uptime — only startup initialization).Impact
Workaround
Manual cleanup of orphan processes by terminating pwsh processes whose parent is a
winpty-agentspawned by acopilotprocess.Affected version
0.0.406
Steps to reproduce the behavior
copilot)powershelltoolGet-Process -Name pwsh | Select Id, @{N='Parent';E={$_.Parent.Id}}winpty-agent → pwshpairExpected behavior
Copilot CLI should terminate
winpty-agentandpwshprocesses after the associated shell session/tool execution is complete, or at minimum reuse existing shell sessions instead of spawning new ones for each tool call.Additional context
No response