Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
Agent Shell / Cursor terminal sessions get stuck in running after the OS process has already finished (or never printed a byte). After that, every later Agent Shell call queues or hangs: git, python, xcodebuild, even a trivial timer/sleep “watch the log” command.
This is not one flaky git repo. The same session-desync happens for:
Xcode: xcodebuild build|test redirected to a log (> tmp/foo.log 2>&1, often started with block_until_ms: 0 / background &). The log already contains TEST SUCCEEDED / TEST FAILED / BUILD SUCCEEDED. The terminal UI still shows running for many minutes. A later inspection can find the pid in the session header already dead, no children.
Python: python -u script.py 2>&1 | tee tmp/foo.log (installers, device scripts, anything that runs >30s). Same zombie running. A second Python one-liner never starts.
Git: git status, git pull, git checkout, git worktree list. In Terminal.app they return instantly. In Agent Shell they sit at running with empty output until the human Aborts.
Basic monitoring: we tried not blocking the PTY: start the job, then later Read/Grep the log, or a short sleep / “wait until the log matches SUCCEEDED”. That monitoring Shell also hangs or never fires. AwaitShell / output-pattern wait is unusable for us — it either never completes or stacks behind the zombie. ps/pgrep as a health check is worse: it queues behind the stuck session and freezes the agent.
We already encoded “one long command at a time; don’t poll; read the log file” as always-on project rules because stacking a second Shell is what makes the product look dead. Those rules do not prevent the first session from lying about running. Abort/Stop in the UI often does not match process lifetime (UI running + pid gone, or Abort with zero stdout so we cannot tell if the command started).
macOS, zsh, Agent mode. Multiple git worktrees. Repro is easiest after any long job or a large checkout, but even git rev-parse --abbrev-ref HEAD has hung with empty output.
Steps to Reproduce
We do not have a 3-line public fixture, but this is consistent on our machine:
Open a medium/large repo in Agent mode (ours is an Xcode iOS app; git worktrees optional but make git hangs more obvious).
From the agent, run a long command with output redirected to a file, and do not keep the PTY in the foreground, e.g.
xcodebuild … test > tmp/run.log 2>&1
or
python -u long_script.py > tmp/run.log 2>&1
with Agent Shell block_until_ms: 0 (or equivalent background).
Wait until tmp/run.log clearly shows a terminal result (TEST FAILED, Python traceback, PASS: installed, etc.).
Observe the Cursor terminal session: it often still says running.
Without Stop-ing that session, ask the agent to run any of:
git rev-parse --abbrev-ref HEAD
python -c ‘print(“ok”)’
sleep 2; echo still-alive
“poll until the log contains SUCCEEDED” / AwaitShell on that log
Result: new Shell hangs, empty output, or never starts. The UI looks frozen.
Stop/Abort the old session. Ask the agent to run the same short command again. It can still hang (empty running until Abort).
Paste the identical short command into Terminal.app → returns immediately.
Optional git-worktree variant: git pull --ff-only in worktree A (large tree). Fast-forward prints in the log, then a chained git status -sb never returns in Agent Shell. git worktree list from the agent hangs; Terminal.app is instant.
Expected Behavior
When the user command’s process (and its process group) has exited, the Agent terminal session must go idle, not stay running.
Redirecting to a file (> log 2>&1) or starting with block_until_ms: 0 must be either fully supported (session completes when the process exits) or rejected immediately — not a zombie session that poisons the next tool call.
After a session is Stopped/Aborted, the next Shell tool call must get a fresh process group and run. Trivial git / python -c / sleep 2 must return in Agent Shell about as fast as in Terminal.app.
Log-file monitoring (Read/Grep the log, or wait-until-regex) must work without attaching to the original PTY. A timer/sleep used only to wait should not hang forever with empty output.
If a command exceeds block_until_ms, the agent should get a clear “moved to background, pid=…” result, and later completion should be observable without opening a second Shell that queues forever.
Operating System
MacOS
Version Information
Cursor Agent (Agent mode, project rules always-on)
macOS darwin 25.6.0, default shell zsh
Large native repo: Xcode iOS app, multiple git worktrees sharing one .git
Typical long job: xcodebuild test (10+ minutes)
Typical short job: git status / git checkout / git worktree list
For AI issues: which model did you use?
grok 4.6
Does this stop you from using Cursor
Sometimes - I can sometimes use Cursor