Terminal Output Capture Bug

Short version: Terminal output is sometimes not captured (or displayed) consistently in Composer using YOLO and Agent mode in windows. I am able to consistently reproduce the problem using the following prompt in a new session:

Run this command and explain if the output is what you would expect and confirm all lines are present and complete:
python -c “n=50; [print(f’Line {i+1}: ’ + ’ '.join([‘test’]*(i+1))) for i in range(n)]”

On a faster PC I have found I may need to increase n to 100, or have it run the command a few times but the problems eventually occur. (missing lines, blank lines instead of expected text, etc.)

I have had what appears to be the same problem with various terminal commands (git, running scripts with longer outputs, etc) and on occasion it leads to the composer not recognizing that the terminal command has completed and it waits forever (hangs).

I am very curious if anyone else is able to reproduce this problem.

And for fun, after having it run the command at least once, ask it to clear the terminal with ‘cls’. For me it hangs (stops) 100% of the time.

Long version (created with help of Cursor/Claude of course)

# Terminal Output Capture Bug Report

## Overview
Testing of terminal command output capture on Windows reveals several issues with buffering, line count limitations, and formatting. The following test command demonstrates all issues:

```bash
python [-u] -c "n=N; [print(f'Line {i+1}: ' + ' '.join(['test']*(i+1))) for i in range(n)]"
  • Replace N with line count (test with 20, 50, and 100)
  • -u flag controls output buffering

Issues and Reproduction

1. Output Capture and Formatting

Without the -u flag, output capture issues are immediately apparent:

# Without -u: Output is incomplete and inconsistent
python -c "n=20; [print(f'Line {i+1}: ' + ' '.join(['test']*(i+1))) for i in range(n)]"

Using -u improves the situation but doesn’t solve it completely:

# With -u: Shows more lines but still has issues with higher counts
python -u -c "n=20; [print(f'Line {i+1}: ' + ' '.join(['test']*(i+1))) for i in range(n)]"

Test cases with N=20, 50, and 100 lines demonstrate that:

  • Output capture behavior varies significantly based on system performance
  • Initial lines display correctly with proper formatting
  • As line count increases:
    • Text wrapping becomes inconsistent
    • Formatting degrades
    • Lines may be dropped or truncated
    • Performance of the system impacts severity and onset of issues

2. Console Commands

  • Commands that manipulate the console (like cls) cause the AI agent’s command execution to hang
  • Issue persists across Windows shells (PowerShell and cmd)
  • Composer occasionally hangs waiting for command output that never appears

3. AI Generation Hanging

  • AI assistant occasionally hangs during response generation
  • Issue has been reported by multiple users
  • Appears to be independent of terminal output issues

Environment Details

Version: 0.44.11
VSCode Version: 1.93.1
Commit: fe574d0820377383143b2ea26aa6ae28b3425220
Date: 2025-01-03T07:59:06.361Z
Electron: 30.5.1
Chromium: 124.0.6367.243
Node.js: 20.16.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22631
Shell: PowerShell
Python: 3.12.7
YOLO Mode: Enabled
LLM Model: claude-3.5-sonnet
Composer in agent mode

Additional Notes

  • Issues persist across different Windows shells (PowerShell and cmd)
  • Output capture issues appear to be related to both buffering and line length
  • Line wrapping issues become more severe as line length increases
  • Output is inconsistent between runs and varies significantly based on system performance, with slower PCs experiencing more pronounced issues
  • Terminal commands that manipulate the console (like cls) cause the AI agent’s command execution to hang
  • Issues persist regardless of terminal window size
  • Composer occasionally hangs waiting for command output that never appears
  • Problems persist after clean re-install of Cursor
  • Issues reproduced on multiple Windows PCs with varying performance characteristics

im completely talking out my ■■■ here – however, consider forcing agent to wrap whatever your doing in a .ps1 (assuming windows) 0- meaning - you can wrpa the exe of a command around other aspects of tracing it…

I’ve found ANY direct terminal commands executed by Cursor anything to be halting…

Wrappers, wrap the rap and talk the tcl to my ack.

Thanks for the suggestion but I have similar problems. I am not familiar with .ps1 files so much but this lead to the first 20 lines being displayed and then the remaining 30 were all blank.

$pythonCmd = “python -u -c "n=50; [print(f'Line {i+1}: ' + ' '.join(['test']*(i+1))) for i in range(n)]”"
Invoke-Expression $pythonCmd

I also tried outputting the original python command to a file. The file contents are correct but if composer tries to display the file in the terminal with ‘type output.txt’ I still get truncation and blank lines. All this displays fine if I run it manually in the cursor IDE terminal window. But when composer runs terminal commands output is somehow lost (not captured).

Edit: If I could get this to work, it would be a simple method to add custom tools, which is actually what got me started down this path.

After further testing, just displaying the contents of a large file in the terminal using the ‘type’ command exhibits the same problem. For example I output the results from the python command in my original post to a file, output.txt. So this file has 50 lines of text. I used the following prompt:

display output.txt in terminal using the type command

and lines14-41 are missing. Other times there might be blank lines in place of the missing lines. In either case the ai doesn’t see the lines either. This demonstrates that in the composer’s terminal output window is failing to capture text on a consistent basis.

Here’s a screenshot: