Where does the bug appear (feature/product)?
Cursor CLI
Describe the Bug
I hit a local data-loss incident that may involve Cursor sandbox state persisting after the Cursor CLI exited and then being inherited by another terminal agent.
I want to be very careful about attribution here: I cannot prove Cursor issued the final deletion. Another agent (OMP) generated the unsafe recursive cleanup command. The reason I’m posting here is that Cursor-specific sandbox state was still present later in the execution path, and I’m trying to determine whether that could have contributed.
I’m not trying to assign blame here—I mainly want to determine whether this is an expected behavior, a bug, or simply an unfortunate interaction between two tools. If there’s any additional logging or diagnostics I can collect to help narrow this down, I’m happy to do so.
Steps to Reproduce
What happened
I ran Cursor CLI in:
/home/jmn/CLIProxyAPI
Cursor exited after I pressed Ctrl+C at:
2026-07-09 18:51:57 UTC
Fourteen seconds later, I launched OMP from the same terminal in the same repository:
2026-07-09 18:52:11 UTC
OMP later spawned several non-isolated workers. One of those workers generated:
TMPDIR=$(mktemp -d)
export PI_MODELS="$TMPDIR/models.json"
export OPENCODE_CONFIG="$TMPDIR/opencode.json"
# ...tests...
rm -rf "$TMPDIR"
The worker should never have reused the reserved TMPDIR variable. That’s an OMP bug, and I’m filing that separately.
After that cleanup, later commands started failing with:
mktemp: failed to create file via template
‘/home/jmn/.cache/tmp/tmp.4tfX7fcJGP/tmp.XXXXXXXXXX’:
No such file or directory
Within roughly 15 seconds, the entire repository directory disappeared.
Timeline (UTC)
- 18:51:57.003 — Cursor session exits/disposes
- 18:52:11.701 — OMP starts in the same terminal and repository
- 19:26:58.807 — OMP worker performs the unsafe
TMPDIRcleanup - 19:26:59.962 — Watcher still sees the repository
- 19:27:15.686 — Watcher reports the repository root is missing
- 19:27:21.491 — Next command fails because the working directory no longer exists
The later shell execution wrapper still contained Cursor-specific state:
__CURSOR_SANDBOX_ENV_RESTORE
dump_zsh_state
The affected temporary path was under:
/home/jmn/.cache/tmp/
Earlier Cursor logs also show that cursorsandbox was active:
sandbox.configureSuccess
sandboxBinary:
/home/jmn/.local/share/cursor-agent/versions/
2026.07.08-0c04a8a/cursorsandbox
What I know
- Cursor CLI ran in the same repository and terminal immediately before OMP.
- Cursor exited only 14 seconds before OMP started.
- Cursor-specific sandbox restoration hooks appeared in the later shell execution path.
- The sandbox temporary directory became invalid.
- The repository disappeared shortly afterward.
- I have no recorded command that explicitly ran:
rm -rf /home/jmn/CLIProxyAPI
What I don’t know
- I don’t know which PID issued the final
unlink/rmdirsyscalls. - Cursor’s visible logs don’t show an explicit cleanup event at the time of deletion.
- I cannot prove Cursor’s sandbox helper deleted the repository.
- I also haven’t yet reproduced this from a completely fresh terminal with no prior Cursor session.
My current working theory is that this was a cross-runtime interaction:
- Cursor initialized sandbox/shell state.
- Cursor exited.
- OMP launched from the same terminal and inherited (or replayed) Cursor-specific shell state.
- An OMP worker corrupted or deleted a sandbox-managed temporary directory.
- A later cleanup path removed a broader directory than intended.
Step 5 is the part I cannot currently prove.
Expected Behavior
Cursor $TMPDIR state not persisting after exit.
Questions for the Cursor team
-
Can
__CURSOR_SANDBOX_ENV_RESTORE(or related shell state) remain active after the Cursor CLI exits? -
Can another terminal application launched afterward inherit Cursor sandbox restoration hooks?
-
What cleanup occurs if a sandbox-managed
TMPDIRis deleted or becomes invalid? -
Are any cleanup paths derived from mutable state like
TMPDIR, the current working directory, or restored shell state? -
Are cleanup targets canonicalized and verified to remain underneath the intended sandbox root before deletion?
-
Is there a diagnostic command or debug mode that can tell whether a shell still has active or stale Cursor sandbox state after the CLI exits?
Operating System
Linux
Version Information
Cursor details
Installed Cursor agent version:
2026.07.08-0c04a8a
Does this stop you from using Cursor
No - Cursor works, but with this issue