PTYs are never closed, eventually causes IDE crash

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Pseudoterminals are not closed when an agent is archived. This causes Cursor to allocate very many terminals, eventually it hits the macOS maximum open terminals limit (512). When this happens, macOS refuses to open more terminals and Cursor crashes

Steps to Reproduce

  1. start an agent, have it run some commands in a shell
  2. archive it
  3. list open ptys

e.g.

❯ sudo lsof /dev/ptmx | sed 1d | awk '{print $1}' | uniq -c
Password:
 303 Cursor
   2 ghostty

Expected Behavior

Cursor needs to manage open PTYs in order to avoid exhausting OS resources

Operating System

MacOS

Version Information

Version: 3.5.33
VSCode Version: 1.105.1
Commit: aac81804b986d739acab348ed96b8bea6e83cc50
Date: 2026-05-22T06:47:48.039Z
Layout: glass
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Darwin arm64 24.6.0

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Thanks for the detailed report.

This is a known issue: background terminals/PTYs created by agent shell commands aren’t always released when an agent is archived, so they accumulate over a session and can eventually hit the macOS open-PTY limit. Our team is actively working on the terminal lifecycle and PTY disposal here, though I don’t have an ETA to share yet.

In the meantime, the reliable way to reclaim the leaked PTYs is to fully quit and reopen Cursor (Cmd+Q, then relaunch) - since the handles in your lsof are held by the live Cursor process, a restart releases them all at once. If you run a lot of agents in one sitting, doing this periodically will keep you well under the 512 limit and avoid the crash.

I’ll keep this thread updated as the fix progresses.