Terminal Command Tool Prematurely Reports Completion

Describe the Bug

The run_terminal_cmd tool in Cursor’s AI assistant incorrectly reports command completion for long-running processes before they actually finish executing.

Environment

Cursor Version: 1.3.4
OS: macOS Darwin 24.5.0
Shell: /opt/homebrew/bin/zsh
AI Model: Claude Sonnet 4

Problem Description

When using the run_terminal_cmd tool for long-running commands (especially build commands like ./gradlew build), the tool returns and reports “Command completed” prematurely while the command is still executing in the terminal.

Steps to Reproduce

Use AI assistant with run_terminal_cmd tool
Execute a long-running command like ./gradlew build in a large project
Observe that the tool returns immediately with just the shell prompt
Check actual terminal - command is still running and producing output

Expected Behavior

The run_terminal_cmd tool should:
Wait for the actual command to complete
Return the full command output (compilation logs, test results, etc.)
Only report “Command completed” when the process actually finishes
Show proper exit codes and full output

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.3.4 (Universal)
VSCode Version: 1.99.3
Commit: bfb7c44bcb74430be0a6dd5edf885489879f2a20
Date: 2025-07-29T03:47:21.131Z
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Darwin arm64 24.5.0

Additional Information

Actual Behavior
The tool:
Returns prematurely with only shell prompt: ➜ my-project git:(feature-branch) ✗
Reports “Command completed” while command is still running
Provides no actual command output or results
Causes AI assistant to incorrectly assume command finished

Evidence/Examples
Working Example (shorter command):

./gradlew :my-app:test --tests “SampleControllerTest
Returns full output including:
Task :my-app:test
Gradle Test Run :my-app:test
[… full test output …]
BUILD SUCCESSFUL in 5s

Broken Example (long-running command):

./gradlew build
Returns immediately with only:
➜ my-project git:(feature-branch) ✗
(No build output, still running in actual terminal)

Impact
AI assistant makes incorrect assumptions about command completion
May attempt to run subsequent commands while builds are still in progress
Breaks automated workflows that depend on build results
Causes confusion and potential race conditions

Suggested Fix
The run_terminal_cmd tool should properly wait for process completion by:
Monitoring actual process exit status
Collecting complete stdout/stderr output
Only returning when the spawned process actually terminates
Workaround
Currently requires manual verification that commands have actually completed before proceeding with AI assistant recommendations.

Does this stop you from using Cursor

Yes - Cursor is unusable

This appears to be similar to this issue. If you interrogate the agent, they have no idea why the command returned too soon and will sometimes blame the user for the premature exit. Turns out there is another model or system that is monitoring terminal commands and reporting when they are “done”. But depending on which shell you are using or what other things are happening in that terminal, the command exit detection can fire prematurely or not at all. I find that if the agent is running any command that takes more than 5 seconds, there’s a very high chance the IDE will ^C and kill it. If it does let the command complete, it will often just sit there until the connection to the agent service times out.

The terminal command tool needs some very important fixes.

thanks @tiz.io for sharing this. Are there any workarounds you know of ?

I’ve tried a few that get me through the day:

Sometimes I wrap critical commands that I run often (like unit tests) in a nohup or script that rejects ^C.

I’ve also made some commands in the background and pipe their output to a log file which I then share back to the agent.

These are all janky hacks and make me want to either create my own CLI MCP or find a different IDE until this is fixed.

The process detection logic Cursor uses right now is just incomplete. The agent’s CLI tool needs to have configurable string monitoring for command completion. It needs to be able to handle long-running commands, shell-wrapping environments (like conda), and interactive CLI applications (like git commit, a REPL, or a mysql cli).

hi @Parvesh_Jain and thank you for the bug report.

Please update to 1.3.5 and let me know if the same issue still happens.
We have deployed bug fixes for several cases but if this one persists more info may be necessary:

  • Could you post a Request ID with privacy disabled so we can look into the details? Cursor – Getting a Request ID
  • Please share errors from Help > Toggle Developer Tools > Console
  • Have a look also at Logs in Command Palette > Open Logs Folder and post any errors here.

@tiz.io could you also check and share details? While it seems similar from usage, the cause is different in this case.

Thanks @condor , the update helped, and I am not seeing premature exits from cursor in last couple of days atleast.

1 Like

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