Terminal Output Handling Issues in Agent Mode

Issue Description

TLDR: The agent cannot read the output of the commands it runs in the terminal or wait for the command to finish, such as a build process.

I have identified consistent issues with how the terminal in Cursor IDE handles command execution and output display, even after adjusting the “Use Preview Box” setting as recommended. When executing commands in the terminal through the IDE’s interface, several problems persist that make debugging and development challenging:

  1. PSReadLine errors continue: Despite disabling the Preview Box, PSReadLine errors with ArgumentOutOfRangeException still occur consistently, suggesting a deeper integration issue.

  2. Incomplete command output: While simple commands may show output, more complex commands with formatted output (like tables) still have inconsistent display.

  3. Background task handling: Commands run in background mode still report as “running” or “interrupted” without showing their complete output.

  4. Terminal history interference: Previous command outputs and errors continue to appear mixed with new command outputs.

Steps to Reproduce

  1. Open Cursor IDE
  2. Go to Settings > Preferences > Terminal and ensure “Use Preview Box” is enabled (as suggested in the workaround)
  3. Open the integrated chat in Agent Mode.
  4. Ask the agent to debug itself and execute a simple command:
    echo "Test message"
    
    • This may work as expected
  5. Execute a more complex command:
    Get-Process | Select-Object -First 5 | Format-Table
    
    • Notice the PSReadLine errors and incomplete output
  6. Try a background command:
    Start-Sleep -Seconds 3; echo "Command completed after 3 seconds"
    
    • Observe how it’s marked as “running in background” without showing completion

Workaround Testing Results

As suggested (Cannot See Output for Agent/Composer in Non-Interactive Terminal - #2 by danperks), I enabled the “Use Preview Box” setting in Settings > Preferences > Terminal. After testing this workaround:

  1. :white_check_mark: Simple, single-line outputs (like echo "Test message") work slightly better
  2. :cross_mark: PSReadLine errors still occur consistently
  3. :cross_mark: Complex command outputs (tables, lists) still display incorrectly
  4. :cross_mark: Background tasks still don’t show completion properly
  5. :cross_mark: Terminal history/state issues persist

Expected Behavior

  1. Terminal should display complete command outputs accurately
  2. No PSReadLine errors should appear during normal operation
  3. Background commands should report completion status and output correctly
  4. Each command’s output should be clearly separated from previous outputs

Actual Behavior

  1. PSReadLine errors continue to appear with the same ArgumentOutOfRangeException
  2. Command outputs are often truncated, missing, or mixed with previous command history
  3. Background commands don’t properly display completion or output
  4. Complex outputs (tables, multi-line results) display poorly or not at all

Environment Information

  • Operating System: Windows 11
  • PowerShell Version: 7.4.6
  • PSReadLine Version: 2.3.5
  • Cursor Version: 0.46.8
  • Settings: “Use Preview Box” enabled in Terminal preferences

Additional Information

The core issue appears to be related to how Cursor interfaces with PowerShell’s console handling, specifically the PSReadLine module. The consistent error is:

System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. (Parameter 'top')
Actual value was 1.
   at System.ConsolePal.SetCursorPosition(Int32 left, Int32 top)

This suggests the terminal buffer is being initialized or managed incorrectly, regardless of the Preview Box setting.

Impact

This issue significantly impacts workflow as it:

  • Makes debugging with terminal output unreliable
  • Requires frequent manual verification of command execution
  • Forces workarounds like redirecting output to files
  • Makes multi-step command sequences difficult to track

Potential Solutions

  1. Provide an option to completely bypass PSReadLine for the integrated terminal
  2. Implement better buffer management for the PowerShell console
  3. Add a “raw mode” terminal option that prioritizes output reliability over features
  4. Consider implementing a more traditional terminal emulator with fewer integration points

Questions for the Community

  1. Has anyone found a more effective workaround than just disabling the Preview Box?
  2. Are there specific PowerShell profile settings that might help mitigate these issues?
  3. Does anyone know if this is being tracked as a known issue by the Cursor team?

Despite the suggested workaround, the core issues persist. I appreciate any additional suggestions while awaiting a more permanent fix.

1 Like

I can confirm the problem. it does lead to wrong decisions of the model. Its assuming problems where are none.
In my case performing the commands in integrated terminal pane is working correctly.
but when i tell the model to perform the command

run:
Get-Process | Select-Object -First 5 | Format-Table

this is the command claude 3.7 executes:

PS C:\Users\a.sternberg> Get-Process | Select-Object -First 5 | Format-              
Get-Process | Select-Object -First 5 | Format-Tabl                                  
Get-Process | Select-Object -First 5 | Format-Table

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    622      57    19584      61940             14528   0 Agent.Package.Availability
    163       9     1608      11804       0,13   5648   0 agent_ovpnconnect

The command becomes compleately messed up! And the output is truncated.
Why is that? What can we do?

1 Like

doing it once again, this is the output:

PS C:\Users\a.sternberg> G

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName











    560      57    19580      61936             14528   0 Agent.Package.Availability                     
    163       9     1608      11804       0,13   5648   0 agent_ovpnconnect                                                                                                                                       

    143       9     1992       9336              9552   0 AggregatorHost                                                                                                  

    143       9     1992       9336              9552   0 AggregatorHost                                                                                                  

    426      24    11988      36828       0,48  15820   1 ApplicationFrameHost                                                                                            

    728      40    52960      70688              5672   0 AteraAgent                                                                                                      



PS C:\Users\a.sternberg> ^C^C  
PS C:\Users\a.sternberg>       
PS C:\Users\a.sternberg>

notice the double enty in the table and many additional whitespaces.

the truncated command is interesting. for the table to show (even if distorted) the command had to be executed ok by claude.

it seems the shell output is messed with after excecution.
is there an additional cursor ai in play that changes the output of the shell?

what can we do?

1 Like

Can agree that the terminal is screwed up:

ArgumentOutOfRangeException

Using Powershell in Windows