[Bug]: One heavy agent stalls all agents and provider startup on Linux: idle scopes keep their process trees, and providers start inside the throttled agents slice #46836
Summary#
On a Linux host, one heavy agent can stall every other agent and every new provider start for hours. Two gaps cause it:
- An agent scope, and every background process in it, lives on after the session stops working. Nothing ends it until the server stops.
- New provider processes (
codex app-server,claude) start inside the same shared agents slice. When that slice sits atMemoryHigh, they are throttled and miss their initialize timeouts.
Environment#
- 8 vCPU / 16 GB RAM / 8 GB swap VM, Ubuntu 24.04, kernel 6.8, cgroup v2
- T3
0.1.14-nightly.20261128.5385as a systemd user service, agent scopes on app-t3code-agents.slice:MemoryHigh=9.24G,MemoryMax=11.43G,MemorySwapMax=infinity- No systemd-oomd or earlyoom installed
Observed#
- Host swap was 100% full (8191/8191 MB) for about 9 h (03:40–12:20 UTC).
- The agents slice stayed at
MemoryHighall that time. At stop it reported10.0G memory peak, 7.6G memory swap peak.memory.maxwas never hit, and the kernel did not OOM-kill anything. app-t3code.slicememory.eventshigh= 225M.memory.pressurefull total = 40,926 s. 100M major faults.- Load average was 45–104 while the CPU was about 87% idle. iowait was 1–5% and disk await was under 1 ms. The bottleneck was memory throttling, not CPU or disk.
- Codex: five
codex app-serverscopes started 30 s apart. Each failed withCodex app-server did not answer initialize within 30 secondsafter it had used about 1.5 s of CPU. A normal initialize on this host takes about 1 s. - Claude: 14
ClaudeMcpRegistrationTimeoutErrortimeouts, 5 min each, all in the swap-full window. - The main offender was one Claude scope. Its session started
wrangler devand two app dev servers as background commands, then a local CI script. The session's last activity was at 06:55. The scope lived until the server stopped at 12:17 (about 5.4 h later): peak 5.1G + 3.3G swap. At the stop, systemd loggedFailed to kill control group ... Invalid argumentandFailed with result 'timeout'. - Idle pinned delegate sessions held scopes for 214, 80, 60 and 58 min.
- Concurrency was not the cause. Earlier that week 30 runs were active at once without swap trouble. The type of workload (dev servers, test runners,
tsc) drove memory.
Root cause#
MemoryHighwithout a kill path throttles forever. When swap is full, the kernel cannot reclaim the slice's anonymous memory. Every task in the slice then sleeps in thememory.highpenalty and refaults its binary pages. This includes new provider processes. Throttled tasks count in the load average, which is why load was 100 with idle CPUs.- Nothing ends a scope's process tree when its session stops working. Background dev servers keep their memory and swap until the server restarts. (My guess: live background work keeps the idle release from running, as #46329 describes.)
- Provider startup shares the throttled pool, so one offender blocks every new session on the host, on all providers.
Proposed changes#
- End each scope's process tree when its session ends, including background commands. Release idle pinned delegate sessions after a timeout. To keep #41178 working, a dev server that should outlive the session could move to its own unit that the user can see and stop.
- Start provider processes outside the throttled pool, or with reserved headroom. For example, start them in a sibling slice, or move a scope into the agents slice only after initialize. A new session should be able to initialize while other agents sit at
MemoryHigh. - Smaller items:
- Set a finite
MemorySwapMaxon the agents slice, so agents cannot fill all host swap. - Set
MemoryHigh/MemoryMaxon each scope, so one scope hits its own limit before the shared one. - Set
ManagedOOMMemoryPressure=kill(andManagedOOMSwap=kill) on the agents slice, so a stall ends with one kill instead of hours of throttling. WithMemoryHighalone, nothing ever kills the offender.
- Set a finite
Related: #39976 (no MemoryHigh when swap is full; it fixes part of item 2 on the next launch, but not running scopes or idle trees), #43888 (idle ACP scopes and oomd victim choice), #39195, #43662, #41178, #46329.
Workarounds users can apply today#
- Install systemd-oomd and put
ManagedOOMMemoryPressure=kill/ManagedOOMSwap=killin a drop-in forapp-t3code-agents.slice. - Cap each scope with a prefix drop-in, for example
~/.config/systemd/user/t3code-.scope.d/limits.confwithMemoryMax=andMemorySwapMax=. - After each server start, run
systemctl --user set-property --runtime app-t3code-agents.slice MemoryHigh=infinity(from #39195), so the slice reachesMemoryMaxand kills instead of throttling. - Look for stale scopes with
systemctl --user list-units 't3code-*.scope'andsystemd-cgls, and stop the ones whose session is idle. - Start long-lived dev servers in their own unit (
systemd-run --user --unit=<name> ...), not as an agent's background command.
tanstack-source added labelsbug
Sign in to join this conversation.