Cursor agent mode - when running terminal commands often hangs up the terminal, requiring a click to pop it out in order to continue commands

Thanks for reporting a bug you have found in Cursor!
Please add the following info to help us diagnose your issue:

:white_check_mark: Check the forum to ensure the issue hasn’t been reported already
Checked.

:lady_beetle: Provide a clear description of the bug
When I’m running Cursor Agent Mode with Claude 3.7, and I also have MCPs . This is related to the terminal commands that it runs. I have YOLO mode on as well. When it runs certain terminal commands, it hangs with a loading spinner as if it’s waiting for something, and it will only continue if I click “Pop out terminal” and then it runs another terminal command and it hangs again. And I have YOLO mode on, so it should just run automatically without me having to pop out the terminal.

:counterclockwise_arrows_button: Explain how to reproduce the bug (if known)
You just run a prompt that requires terminal commands, like, I don’t know, catting a file.
:camera: Attach screenshots or recordings (e.g., .jpg, .png, .mp4).
The command completes, and then it hangs.
:laptop: Tell us your operating system and your Cursor version (e.g., Windows, 0.x.x).
Mac OS operating system latest version, and cursor is on the latest version 0.46.9
:prohibited: Tell us if the issue stops you from using Cursor.
Now it’s just tedious having to click “Pop Out” terminal. I’d like it to run all the commands without me having to interrupt. I just wanna vibe code.

11 Likes

I’m having the same issue, however I have a “Cancel and resume” button. It kicks it back into gear but it’s annoying. For me it was working fine most of the day and then started hanging. Mostly happens with cargo commands (using Rust) like cargo test.

3 Likes

Having the same issue, it is extremely annoying: [BUG] Terminal tool gets stuck after exit code

Same issue here

1 Like

Same

Feel more frequently recently.

2 Likes

Exact same issue here

Same. The agent cannot obtain the output of the command line tool. This seriously affects the usage.

Same here.

In case this is helpful to folks, my Cursor Chat eventually self-solved these hanging terminals by appending 2>&1 | cat to its commands, suggesting at least sometimes the problem is the stream from Terminal command not terminating or terminating inappropriately.

1 Like

I’ve built a makeshift solution. You can check it out here:

AgentShell-optimized

same issue, exactly the same setup, on mac os x

Happening a lot.

1 Like

having the same issue here guys, please fix!

got the same with version 0.49.6.

Since unfortuantely Cursor is still silent about this issue. Here is what worked for me. Cursor would hang after running terminal commands (especially in Agent Mode), and I’d have to click to pop the terminal out to continue. I’m using Zsh + Powerlevel10k + Nerd Fonts on macOS.

Turns out Cursor seems to be unable to detect when the command finished because the Powerlevel10k prompt is too complex, especially with glyphs and async segments.

:wrench: Solution: Use a minimal prompt inside Cursor only

I fixed it without giving up Powerlevel10k in other terminals (like iTerm2) by:

  1. Detecting if I’m inside Cursor (TERM_PROGRAM == “vscode”).
  2. Disabling the Powerlevel10k theme and prompt in that case.
  3. Falling back to a simple, clean prompt just for Cursor.

:puzzle_piece: Final .zshrc snippet

# Set Oh My Zsh theme conditionally
if [[ "$TERM_PROGRAM" == "vscode" ]]; then
  ZSH_THEME=""  # Disable Powerlevel10k for Cursor
else
  ZSH_THEME="powerlevel10k/powerlevel10k"
fi

# Load Oh My Zsh
source $ZSH/oh-my-zsh.sh

# Use a minimal prompt in Cursor to avoid command detection issues
if [[ "$TERM_PROGRAM" == "vscode" ]]; then
  PROMPT='%n@%m:%~%# '
  RPROMPT=''
else
  [[ -f ~/.p10k.zsh ]] && source ~/.p10k.zsh
fi

:white_check_mark: After restarting Cursor (exec zsh or close/reopen), it now properly detects command completion — no more hangs, no need to click or pop out the terminal.

:light_bulb: Optional: You can use something like vcs_info to add Git branch info to the minimal prompt if needed.

Hope this helps others facing the same annoying issue!

10 Likes

Works like a charm! Thanks a ton!

@jomis Thats a very good find! I was also not aware this could be a cause. It might be depending on the user and likely hard to control for Cursor as some users require certain shells. Will pass link to your solution here in other threads. Thanks!

Crossing my fingers this works – just now testing it out.

Curious though – any idea how we might be able to do this STRICTLY for Cursor’s in-chat terminal, but not in the user terminals? I don’t care what the Agent sees, but makes me sad to not have my theme where I’m using the terminal :stuck_out_tongue:

I recently encountered this issue while using a remote-devcontainer environment via Remote-SSH, and I’d like to share the solution in case others run into the same problem.
If you’re using Remote-SSH with a devcontainer and face a similar issue, the following workaround should help.

In short, the root of the problem turned out to be that shell-integration with cursor (VS Code) wasn’t functioning properly, preventing the tool from detecting when commands had finished executing.
Normally, when you launch a shell in cursor (or VS Code), you’ll notice small indicators—like a white ○, red ◎, or blue ●—at the left of the prompt. These markers signify that shell-integration is working.

However, when launching a terminal in cursor’s agent mode, these indicators sometimes don’t appear—indicating that shell-integration isn’t active.
You can also verify the status of shell integration with the following command:

code --locate-shell-integration-path zsh

If this command returns a file path (typically something like .../shellIntegration-rc.zsh), shell-integration is set up correctly. If it throws an error—or if code isn’t installed on the remote environment—then shell-integration isn’t functioning as it should.

In my case, the first step was installing VS Code on the remote environment.
Additionally, since I was (admittedly unwisely) running the devcontainer as root, I needed to add the following line to .zshrc:

[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path zsh --user-data-dir='.' --no-sandbox)"

Once the code --locate-shell-integration-path zsh --user-data-dir='.' --no-sandbox command began returning a valid path, the shell in agent mode started properly reporting execution status, and the agent no longer hung.

Hope this helps someone out there. Happy engineering!

1 Like