[Bug] Agent Shell broken on Chinese Windows - "Add-Content: Stream was not readable" errors

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Bug Report: Agent Shell floods “Add-Content: Stream was not readable” errors on Chinese Windows

Cursor Version

  • Version: 2.6.11 (system setup)
  • VSCode Version: 1.105.1
  • Commit: 8c95649f251a168cc4bb34c89531fae7db4bd990
  • Date: 2026-03-03T18:57:48.001Z
  • Electron: 39.6.0
  • Node.js: 22.22.0

Operating System

Windows_NT x64 10.0.19044 (Chinese Simplified, Code Page 936/GBK)

Steps to Reproduce

  1. Use Cursor on a Chinese Windows system (system locale: Chinese Simplified, code page 936)
  2. Start a new Agent chat session
  3. Ask Agent to run any shell command, e.g., echo test or python --version

Expected Behavior

The command output should be displayed cleanly without errors.

Actual Behavior

Every shell command execution produces massive Add-Content : Stream was not readable errors:

Add-Content : 流不可读。
 所在位置 C:\Users\Administrator\AppData\Local\Temp\ps-script-xxx.ps1:19 字符: 9 
+         Add-Content -Path $OutputFile -Value $Content -Encoding UTF8 
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     + CategoryInfo          : InvalidArgument: (...txt:String) [Add-Content], ArgumentException
     + FullyQualifiedErrorId : GetContentWriterArgumentError,Microsoft.PowerShell.Commands.AddContentCommand

This error repeats dozens or hundreds of times per command, flooding the output. The actual command usually still executes successfully (exit code 0), but the output is buried in errors.

Root Cause Analysis

  • Cursor Agent Shell generates temporary PowerShell scripts (ps-script-xxx.ps1) in %TEMP%
  • These scripts use Add-Content -Path $OutputFile -Value $Content -Encoding UTF8 to capture output
  • The -Encoding UTF8 parameter conflicts with the default GBK/GB2312 encoding on Chinese Windows (code page 936)
  • This causes “Stream was not readable” errors

Environment Details

Item Value
System Code Page (ACP/OEMCP) 936 (GBK)
PowerShell Version 5.1.19041.1682
[Console]::OutputEncoding GB2312 (default)
PowerShell Profile Not present (all 4 locations)

What I’ve Tried (None Worked)

1. VS Code Terminal Settings:

"terminal.integrated.automationProfile.windows": { 
    "path": "C:\\Windows\\System32\\cmd.exe" 
}, 
"terminal.integrated.defaultProfile.windows": "Command Prompt" 

Result: No effect on Agent Shell (it uses its own execution mechanism)
2. PowerShell UTF-8 Configuration:

# PowerShell Profile 
if (!(Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force }
Add-Content -Path $PROFILE -Value '[Console]::OutputEncoding = [System.Text.Encodin
g]::UTF8'

# Python UTF-8 environment variables [Environment]::SetEnvironmentVariable("PYTHONUTF8", "1", "Machine") [Environment]::SetEnvironmentVariable("PYTHONIOENCODING", "utf-8", "Machine")

# System locale 
setx LANG zh_CN.UTF-8 

Result: No effect on Agent Shell

3. System Reboot:
Result: Issue is intermittent - sometimes disappears after reboot, but comes back later

Additional Notes

  • This issue is intermittent - sometimes the errors appear, sometimes they don’t, with no clear pattern
  • User commands in Cursor’s integrated terminal work fine - only Agent Shell is affected
  • The command itself usually executes successfully; errors are just noise

Suggested Fix

Consider using -Encoding Default instead of -Encoding UTF8 in the generated PowerShell scripts, or detect the system encoding and use an appropriate value.

Steps to Reproduce

  1. Use Cursor on a Chinese Windows system (system locale: Chinese Simplified, code page 936)
  2. Start a new Agent chat session
  3. Ask Agent to run any shell command, e.g., echo test or python --version

Operating System

Windows 10/11

Version Information

  • Version: 2.6.11 (system setup)
  • VSCode Version: 1.105.1
  • Commit: 8c95649f251a168cc4bb34c89531fae7db4bd990
  • Date: 2026-03-03T18:57:48.001Z
  • Electron: 39.6.0

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the detailed report. The root cause analysis is especially helpful.

It looks like this is a bug in how Agent Shell generates its temporary PowerShell scripts. A hardcoded -Encoding UTF8 parameter in Add-Content doesn’t play well with GBK systems (code page 936). I’ll pass this to the team.

As a temporary workaround until it’s fixed, have you tried enabling the Windows option “Use Unicode UTF-8 for worldwide language support”? (Control Panel > Region > Administrative > Change system locale > check the beta UTF-8 option). This sets the system code page to 65001 (UTF-8) and may resolve the conflict. Note that this is a system-wide change and requires a reboot.

Let me know if this helps or causes any other issues.

Thanks for the suggestion! Enabling “Use Unicode UTF-8 for worldwide language support” (code page 65001) does completely resolve the Agent Shell issue - no more “Add-Content: Stream was not readable” errors.

However, this system-wide change causes encoding issues with some legacy applications. For example, MobaXterm now displays garbled text after enabling UTF-8 mode.

I’ll keep using the UTF-8 workaround for now and try to find alternative tools for the affected applications. But it would be great if Agent Shell could be fixed to work with non-UTF-8 code pages natively, so users don’t have to choose between Cursor and their other tools. Thanks again for passing this to the team!

1 Like

Update: Comprehensive Findings on “Stream Was Not Readable” Issue

Thanks for the suggestion! Here’s a complete update on my investigation:


1. UTF-8 Global Support — Partially Effective

I enabled “Use Unicode UTF-8 for worldwide language support”
(Code page changed to 65001)

Result: The errors still occur intermittently, even with UTF-8 enabled.

Additionally, this setting causes side effects — some legacy applications (e.g., MobaXterm) now display garbled text.


2. System Configuration — Completely Clean

I’ve verified my system is now in a clean state:

Item Status
PowerShell Profile Does not exist
PYTHONUTF8 Not set
PYTHONIOENCODING Not set
LANG Not set
Code Page 65001 (UTF-8)

The errors persist even with a completely clean system configuration.


3. Clean Reinstall — Did Not Help

I completely reinstalled Cursor and deleted all config data:

  • C:\Users\Administrator\.cursor
  • C:\Users\Administrator\AppData\Roaming\Cursor
  • C:\Users\Administrator\AppData\Local\Cursor

The problem persists after a clean reinstall.


4. Important Behavioral Patterns Observed

Pattern A: Session-Related

  • After system reboot, errors are absent for a short period
  • After creating new chat sessions, errors start appearing again

Pattern B: Cumulative

  • The errors seem to increase over time within a session
  • A simple echo "test" command produces dozens of “Stream was not readable” errors
  • The longer I use Agent Shell, the more errors appear per command

This suggests there may be a resource leak or cumulative state issue in how Agent Shell manages its temporary PowerShell scripts.


5. Timeline

  1. Initially executed PowerShell UTF-8 configuration commands (Profile, environment variables)
  2. Agent Shell started showing “Stream was not readable” errors
  3. Removed all configurations and reinstalled Cursor
  4. Enabled Windows UTF-8 global support
  5. Errors persist intermittently, increasing over time

Conclusion

The issue appears to be within Cursor Agent Shell itself, not caused by:

  • System encoding settings (tested with both 936 and 65001)
  • User PowerShell Profile or environment variables
  • Cursor installation/configuration

The cumulative nature of the errors and the pattern of “works briefly after reboot, degrades over time” suggest a possible file handle leak or stream management issue in the temporary PowerShell script handling.

Looking forward to a fix from the team!

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.