Intermittent/Incomplete Terminal Output Capture Issue with PowerShell Scripts

Dear Cursor Tooling Development Team,

This report details an issue observed during a pair-programming session using the run_terminal_cmd tool to execute PowerShell scripts (.ps1).

Problem Description:

The output received from the run_terminal_cmd tool after executing PowerShell commands/scripts is often incomplete and unreliable. Specifically:

  1. The captured output frequently contains artifacts or remnants from previously executed commands, making it difficult to discern the result of the current command.

  2. The final lines of output from the script, particularly a dedicated “FINAL STATUS” message designed to be the last output, are often missing in the captured terminal response.

  3. Attempting to clear the host (e.g., using Clear-Host within the command string) before executing the main script also seems to contribute to the unreliability of the subsequent output capture.

This behavior contrasts with the user’s direct view of the terminal, which correctly displays the full and accurate output, including the final status message. This suggests the issue lies within the tool’s mechanism for capturing and relaying the terminal output, rather than in the script’s output generation itself.


Text: As can be seen, the terminal output I receive contains many artifacts from previous commands and is often truncated, failing to display the complete execution result, including the final status message. This confirms that the issue lies not in the script itself, but in the way the terminal is being accessed through this interface.

Explain how to reproduce the bug:

While the exact conditions are intermittent, the issue was consistently observed when executing a PowerShell script (gitsync.ps1) that performs API calls and outputs structured information using Write-Output and Write-Host. The problem was particularly evident when attempting to clear the host (Clear-Host) before executing the script or when executing multiple commands in quick succession. A simple script printing several lines followed by a final distinct line might help replicate.

Impact:

This issue significantly hinders the AI’s ability to reliably confirm the success or failure of terminal operations, requiring manual verification from the user for almost every command execution.

User Hypothesis:

The user suggests that perhaps adding a mandatory Clear-Host (or cls) at the very beginning of the underlying terminal process before executing the user-requested command string might help, although this was not conclusively proven effective during our debugging.


This text was generated by the AI assistant based on debugging interactions with the user regarding the gitsync.ps1 script development.

Thank you for looking into this issue.


Operating System: Win11 23H2 22631.5335
Cursor Version: 0.50.4
Agent: Google Gemini 2.5 Pro

1 Like

Having the same issue very consistently. virtually any command run within the chat results in the model not seeing the output correctly: almost always end up with something like
“It’s a bit hard to follow the exact sequence from the terminal output due to the rendering issues and command history, but it seems you ran:”

Actually, I’ve only encountered this problem in one script out of three.
I have PowerShell scripts in two projects in different languages through which linters, compiler and AI use it for code self-diagnostics. But here I tried to make a script that reports problems and successes itself and the AI could not use it. The second screenshot shows how AI tells me that AI has not seen anything at all except the terminal command itself.

I’m facing a similar issue but more with running commands themselves - ps commands will intermittently run then fail - but the AI will continue as though the command has run fine.