Agent not detecting that a command has completed

I am running Cursor 0.47.5, macOS, with zsh shell and oh-my-zsh.

When using agent mode, I find that often it seems like the command ending is not being detected. The built in terminal in the AI pane just seems to sit there. I have attached a screenshot.

I am not sure that if there is something with my .zshrc configuration that is causing this difficulty.

Screen Recording 2025-03-16 at 10.40.10 AM

This definitely slows me down a lot. I cannot consistently reproduce this.

4 Likes

I’m getting this too. Very frustrating. Especially since the agent then thinks there’s something wrong with the command because it was skipped.

Are you running any special kinds of terminal or .zsh?

Same for me.

Zsh with oh-my-zsh but I tried telling it to switch into bash before running the command. I think maybe it has more to do with the structure of the output. It’s happening with long scripts or with running a test suite. I did try to asking it to put a watch word like “END OUTPUT” after the command but that didn’t help it.

Prompt:

@https://forum.cursor.com/t/agent-not-detecting-that-a-command-has-completed/65052/4 
solution? you have this bug. how to solve this?
run echo first

Solution:

Now let's try running it with a simpler command and redirecting both stdout and stderr:

python test.py 2>&1

+1 with the exact same problem. The solution of 2>&1 does nothing to address it. I do use zsh and p10k, so I suspect something might be interfering in there. But I don’t really know how to investigate what is happening

using bash and the same issue there.
it happened randomly. Mostly with command that take longer time. (like compile, but also happen on short command like ls…)

I am on WSL with zsh and oh-my-zsh and same problem. Also it routinely runs commands that succeed but is unable to see the results especially with pytest. and the command runs and I see the output in the agent window but Cursor fails to see it

1 Like

This is a constant snag.
30% it works as expected
30% it doesn’t detect command exited
20% nothing shows up in the terminal at all but the agent can see the output; i have to guess when to hit cancel to proceed
10% nothing shows up and it doesn’t think anything ran
10% it terminates the command very quickly and then declares success before the command completed

Edit: I also use zsh

  1. Ask it to use some other specific shell command, or prefix/sufix/wrap any shell commands in another command, like sh/bash, or maybe run “exit” automatically after each shell instance
  2. Press Ctrl+C or Ctrl+D after clicking the shell text, this might force terminate the shell terminal
  3. Pop-out! This usually causes the Agent to believe it failed, maybe it will check if it’s done or try something else

I used the approach described in this thread to force bash instead of zsh and it is much more reliable now.
Definitely seems there’s something about zsh that throws the IDE or agent off.

1 Like