You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
On macOS every open Claude session runs ps -A once a second, which floods endpoint security with process launches #37582
I searched existing issues and did not find a duplicate.
I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
On macOS, run T3 Code Nightly 0.1.10-nightly.20261113.4643 (current main has the same code).
Keep a number of Claude threads open, idle or working. Delegated Claude tasks count as threads too.
Trace process launches by the server, for example with eslogger exec or any EDR console.
On one Mac with 17 open Claude sessions, a 154 second exec trace recorded 9,200 process launches. 2,079 came from the T3 server, and 1,887 of those were
ps -A -o pid=,ppid=,pgid=,lstart=
That is 12.3 a second on average. It was 23 percent of every process launch on the machine.
Expected behavior
Tracking Claude CLI descendants on macOS costs a bounded number of process launches that does not grow with the number of open sessions, and idle sessions cost close to nothing.
Actual behavior
#34505 added a descendant tracker in ClaudeAdapterV2.ts for #34459. When a Claude CLI has no agent scope unit, which is always true on macOS, trackDescendants runs ps -A -o pid=,ppid=,pgid=,lstart= on Schedule.spaced("1 second") for the life of the CLI process. Each session runs its own ps with nothing shared, and sessions stay open between turns. The PR notes the cost as one ps per second per open Claude session.
Every process launch is expensive on a Mac with endpoint security software. Microsoft Defender, CrowdStrike, SentinelOne and similar tools inspect each exec through the Endpoint Security framework, so the poll turns into constant EDR work and log volume on top of the fork and exec cost. With many parallel agent threads it was one of the three largest sources of launches on this machine, alongside builds and agent hooks.
Suggestions
Any one of these would remove most of the cost.
Share one process table read across all trackers. A single server level poller that runs ps once per tick and hands rows to every live tracker makes the rate one a second instead of one per session.
Use libproc instead of a subprocess. proc_listallpids plus proc_pidinfo(PROC_PIDTBSDINFO) gives pid, ppid, pgid and start time with no exec at all.
Poll less when nothing changes. Back off to several seconds while the CLI's descendant set is unchanged or while the session is idle with no running tool, and refresh immediately on tool start, tool end, session close and CLI exit, which are the moments that matter for cleanup.
Let me know if a trace or more numbers would help.
Additional data point (T3 Code Nightly 0.1.11-nightly.20261117.4825, macOS 27.2.1, 18 cores, 48 GB RAM): with about 70 open Claude sessions, about 4 of these ps -A -o pid=,ppid=,pgid=,lstart= processes are running at any moment (116 seen across 30 process-table snapshots taken 0.1 s apart). That is consistent with one scan per second per session, about 70 per second, each taking roughly 50 ms to walk about 3,700 processes. So the cost grows with open sessions times total process count. Measured at the same time: load average 30–38, CPU 67 % system / 30 % user / 4 % idle, about 1,400 process launches per second machine-wide. One shared tracker for all sessions, for example a single ps per tick or a kqueue NOTE_FORK/NOTE_EXIT watch, or a much longer interval for idle sessions would remove most of this.
Another data point, from 0.1.10 stable on a Mac mini (12 cores, 48 GB, 1,000 to 1,300 processes) with 15 open Claude sessions. In about 45 minutes the server launched ps -A -o pid=,ppid=,pgid=,lstart= 10,521 times, against 10,508 ClaudeAgentSdkQueryRunner.trackDescendants spans, and logged 84 to 95 event-loop stalls an hour of 2 to 5 s each. The root page took 3 to 9 s to answer.
Beyond the EDR cost, uv_spawn blocks the event loop. An 8 s sample of the main thread had about 50% in posix_spawn under a timer, about 30% in the stdout callback (flatMap, Set lookups, string internalization) and almost no idle time. The host was also busy with builds and emulators (load 70 to 120), but a second sample the next day at load 35 showed the same split. Restarting the server helped only until the sessions reopened.
Same cause on Linux, with numbers from a small host (2 cores / 16 GB, gVisor), t3 v0.1.11-nightly.20261119.4928.
First measurement (8 live Claude agents, server.trace.ndjson effect spans plus top): over a 25-minute window t3 serve started 4169 child processes (2.8/s). ps was 2169 of them (1.4/s, about 570 ms each, about 1235 s of wall time in total), all from ClaudeAgentSdkQueryRunner.trackDescendants. It is one ps poll every 1-3 s per active Claude turn, so the cost scales with concurrent turns. A direct ps -e on the same host takes about 0.08 s; the multiplier is spawning from a roughly 1 GB Node process (gVisor makes fork/exec expensive). After a container restart t3 serve was 58 % of the sampled CPU (average 12.5 % of 2 cores, peak 44 %).
Second measurement (3 active Claude agents only): T3 resolves ps through PATH, so we put a counting wrapper first on PATH. 932 calls of ps -A -o pid=,ppid=,pgid=,lstart= in 8 minutes (about 2 per second) with just 3 agents; the port-discovery call (-A -o pid=,ppid=,pgid=) did not run at all in that window. A 3 s cache inside the wrapper answered 84 % of the calls without running the real ps, but the process spawn itself is the cost, so a wrapper cannot remove it: the throttle has to be in process.
Suggestion: in makeClaudeDescendantTracker(...).refresh, return the previous process table when the last real read is younger than a TTL (a few seconds is enough: the tracker keys rows by pid + start time), or share one poll across all turns, or on Linux read /proc directly instead of spawning ps. Happy to test a build.
Follow-up with a measured fix on the same host (t3 v0.1.12-nightly.20261121.5051, 2 cores / 16 GB, gVisor).
We patched makeClaudeDescendantTracker(...).refresh so that the process-table read (ps -A -o pid=,ppid=,pgid=,lstart=) is memoised in process for 5 s on the shared readProcessTable effect: concurrent trackers reuse the last table, and the exit-time leftovers read always stays fresh (so an escaped grandchild is still reaped). The edit is length-preserving on the SEA asset binMain.mjs, and a test harness with a fake claude that speaks the SDK stream-json protocol (no model quota) compares stock and patched on throwaway instances:
ps spawns per minute
stock 0.1.11-nightly.20261119.4928
238.6
stock 0.1.12-nightly.20261121.5051
233.6
patched, same load
12.0 (both versions)
Both boot, t3 status and a smoke thread pass, and a setsid grandchild whose CLI exited is still reaped. On the live server (3 active Claude agents) the rate went from about 116 per minute to about 12 per minute after the restart. The trade-off: descendants are seen up to 5 s later.
So a TTL memo (or one shared poll for all turns) in refresh is enough to take this cost from "per turn event" to a constant, which is what makes 20-30 concurrent agents on one small host plausible. Happy to turn it into a PR against the source if that is useful.
Fixed by #37585, now on main: With several Claude sessions open on macOS or Linux without an agent scope, tracing process launches should now show one shared periodic ps process-table read per second rather than one per session, implementing the report's first suggested solution.
Activity
6vers commentedon Nov 17, 2026
Additional data point (T3 Code Nightly 0.1.11-nightly.20261117.4825, macOS 27.2.1, 18 cores, 48 GB RAM): with about 70 open Claude sessions, about 4 of these
ps -A -o pid=,ppid=,pgid=,lstart=processes are running at any moment (116 seen across 30 process-table snapshots taken 0.1 s apart). That is consistent with one scan per second per session, about 70 per second, each taking roughly 50 ms to walk about 3,700 processes. So the cost grows with open sessions times total process count. Measured at the same time: load average 30–38, CPU 67 % system / 30 % user / 4 % idle, about 1,400 process launches per second machine-wide. One shared tracker for all sessions, for example a singlepsper tick or a kqueueNOTE_FORK/NOTE_EXITwatch, or a much longer interval for idle sessions would remove most of this.hergert commentedon Nov 18, 2026
Another data point, from 0.1.10 stable on a Mac mini (12 cores, 48 GB, 1,000 to 1,300 processes) with 15 open Claude sessions. In about 45 minutes the server launched
ps -A -o pid=,ppid=,pgid=,lstart=10,521 times, against 10,508ClaudeAgentSdkQueryRunner.trackDescendantsspans, and logged 84 to 95 event-loop stalls an hour of 2 to 5 s each. The root page took 3 to 9 s to answer.Beyond the EDR cost,
uv_spawnblocks the event loop. An 8 ssampleof the main thread had about 50% inposix_spawnunder a timer, about 30% in the stdout callback (flatMap, Set lookups, string internalization) and almost no idle time. The host was also busy with builds and emulators (load 70 to 120), but a second sample the next day at load 35 showed the same split. Restarting the server helped only until the sessions reopened.RayFungHK commentedon Nov 22, 2026
Same cause on Linux, with numbers from a small host (2 cores / 16 GB, gVisor),
t3 v0.1.11-nightly.20261119.4928.First measurement (8 live Claude agents,
server.trace.ndjsoneffect spans plustop): over a 25-minute windowt3 servestarted 4169 child processes (2.8/s).pswas 2169 of them (1.4/s, about 570 ms each, about 1235 s of wall time in total), all fromClaudeAgentSdkQueryRunner.trackDescendants. It is onepspoll every 1-3 s per active Claude turn, so the cost scales with concurrent turns. A directps -eon the same host takes about 0.08 s; the multiplier is spawning from a roughly 1 GB Node process (gVisor makes fork/exec expensive). After a container restartt3 servewas 58 % of the sampled CPU (average 12.5 % of 2 cores, peak 44 %).Second measurement (3 active Claude agents only): T3 resolves
psthroughPATH, so we put a counting wrapper first onPATH. 932 calls ofps -A -o pid=,ppid=,pgid=,lstart=in 8 minutes (about 2 per second) with just 3 agents; the port-discovery call (-A -o pid=,ppid=,pgid=) did not run at all in that window. A 3 s cache inside the wrapper answered 84 % of the calls without running the realps, but the process spawn itself is the cost, so a wrapper cannot remove it: the throttle has to be in process.Suggestion: in
makeClaudeDescendantTracker(...).refresh, return the previous process table when the last real read is younger than a TTL (a few seconds is enough: the tracker keys rows by pid + start time), or share one poll across all turns, or on Linux read/procdirectly instead of spawningps. Happy to test a build.RayFungHK commentedon Nov 22, 2026
Follow-up with a measured fix on the same host (
t3 v0.1.12-nightly.20261121.5051, 2 cores / 16 GB, gVisor).We patched
makeClaudeDescendantTracker(...).refreshso that the process-table read (ps -A -o pid=,ppid=,pgid=,lstart=) is memoised in process for 5 s on the sharedreadProcessTableeffect: concurrent trackers reuse the last table, and the exit-timeleftoversread always stays fresh (so an escaped grandchild is still reaped). The edit is length-preserving on the SEA assetbinMain.mjs, and a test harness with a fakeclaudethat speaks the SDK stream-json protocol (no model quota) compares stock and patched on throwaway instances:psspawns per minuteBoth boot,
t3 statusand a smoke thread pass, and asetsidgrandchild whose CLI exited is still reaped. On the live server (3 active Claude agents) the rate went from about 116 per minute to about 12 per minute after the restart. The trade-off: descendants are seen up to 5 s later.So a TTL memo (or one shared poll for all turns) in
refreshis enough to take this cost from "per turn event" to a constant, which is what makes 20-30 concurrent agents on one small host plausible. Happy to turn it into a PR against the source if that is useful.juliusmarminge commentedon Nov 23, 2026
Fixed by #37585, now on main: With several Claude sessions open on macOS or Linux without an agent scope, tracing process launches should now show one shared periodic ps process-table read per second rather than one per session, implementing the report's first suggested solution.