[Bug]: Under Linux cgroup memory pressure, systemd-oomd kills active sessions/workers while idle ACP scopes sit untouched for 30 minutes #43888
Before submitting#
- 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#
- Run
t3(v0.1.12) as a systemd user service on Linux withsystemd-oomdactive (ManagedOOMMemoryPressure=killonuser@1000.service) and a bounded cgroup memory limit onapp-t3code.slice(e.g.MemoryHigh=36G,MemoryMax=40G,MemorySwapMax=0). - Run a parent Claude session that fans out ~12+
delegate_taskworkers on an ACP provider (Antigravity) alongside other recent ACP threads. - Let delegated ACP workers complete and deliver their results while new workers and the parent session keep allocating.
- Observe
app-t3code.slicememory usage andjournalctl -u systemd-oomd.
Expected behavior#
- Completed, delivered
delegate_taskACP child sessions should not hold ~650–1,000 MiB of resident RAM (antigravity acp+t3 acp-mcp-bridge+ MCP servers) for 30 minutes after finishing, and idle sessions should be shed before the agents cgroup hits memory pressure. - Under
systemd-oomdpressure, idle scopes should be preferred victims over active user sessions and active workers.
Actual behavior#
- Finished ACP delegated workers stay alive for 30 minutes: PR #41174 lowered
DEFAULT_IDLE_TIMEOUT_MSto 2 minutes (addressing #26413 for Claude), butAcpProviderCapabilitiesV2declaressupportsNativeResume: false, so every idle ACP session — including one-shotdelegate_taskworkers whose result has already been delivered — falls back toNO_NATIVE_RESUME_IDLE_TIMEOUT_MS(30 minutes). Each idle ACP scope holds ~650–850 MiB of anonymous RAM (antigravity acp~350 MiB,t3 acp-mcp-bridge~260 MiB, plus MCP child processes). With ~15 idle ACP scopes sitting alongside ~12 active workers, resident memory accumulates to ~20+ GiB and pushesapp-t3code.sliceintoMemoryHighreclaim. systemd-oomdvictim inversion kills active sessions first: All scopes underapp-t3code-agents-*.slicelaunch with identical OOM settings (noManagedOOMPreferencedistinction between idle/delegated scopes and active user sessions). Becausesystemd-oomdranks victims bypgscan(reclaim activity) rather than RSS, idle 700 MiB–1.5 GiB ACP scopes (pgscan ≈ 0) are ignored while actively allocating sessions get killed first — including the active parent Claude session at 251.5 MiB and a newly started worker at 205.5 MiB.
Related: #26413 (same 30-minute delegate retention for Claude prior to #41174), #43662 (cgroup memory.swap.max=0 / MemoryHigh pressure stalls).
Impact#
Major degradation or frequent failure
Version or commit#
v0.1.12
Environment#
Ubuntu Linux x86_64 (kernel 7.0, cgroup v2, systemd-oomd enabled), t3 v0.1.12 systemd user service, Claude + Antigravity ACP providers
Logs or stack traces#
# systemd-oomd kills active low-RSS sessions with high pgscan while 15+ idle ~700 MiB ACP scopes remain untouched:
systemd-oomd: Considered 58 cgroups for killing, top candidates were:
Path: .../app-t3code-agents-<hash>.slice/t3code-claude-5a0fad77.scope
Pressure: Avg10: 14.09, Avg60: 5.38, Avg300: 1.30, Total: 4s
Current Memory Usage: 251.5M
Pgscan: 23640221
Killed .../t3code-claude-5a0fad77.scope due to memory pressure for .../user@1000.service being 80.67% > 50.00% for > 20s with reclaim activity
systemd-oomd: Considered 61 cgroups for killing, top candidates were:
Path: .../app-t3code-agents-<hash>.slice/t3code-acp-811e5060.scope
Current Memory Usage: 205.5M
Pgscan: 13270486
Killed .../t3code-acp-811e5060.scope due to memory pressure ... 72.75% > 50.00% for > 20s
systemd-oomd: Killed .../t3code-acp-ae2ec1b4.scope (529.4M, Pgscan: 1395571)
systemd-oomd: Killed .../t3code-acp-dfe90852.scope (762.8M, Pgscan: 32552481)
systemd-oomd: Killed .../t3code-acp-4b36b5e4.scope (1.6G, Pgscan: 196120705)
Workaround#
Reducing concurrent delegated ACP workers or waiting 30 minutes between waves for NO_NATIVE_RESUME_IDLE_TIMEOUT_MS to release finished ACP scopes.
tanstack-source added labelsbug
Thanks for the numbers — good to see the same 30-minute idle-scope buildup reproducing on smaller 4 GB VMs as well, and interesting that
ManagedOOMSwap=killordered idle sessions ahead ofManagedOOMMemoryPressure=killuntil fast fills hit the kernel OOM killer.Agree that releasing idle no-native-resume sessions under memory pressure (or making the 30-minute keep configurable) would address both cases.
Sign in to join this conversation.
Same root on small machines, with numbers in case they help.
Setup: t3 v0.1.11 and v0.1.13 as a systemd user service on Ubuntu VMs with 4 GB RAM, zram swap (systemd-zram-generator's default, half of RAM), agent scopes on (so
app-t3code-agents.slicegets MemoryHigh ≈ 2 GB, MemoryMax ≈ 3 GB).agyplus its bridge) holds 110–300 MB for the 30-minute no-native-resume keep. About 4 fit beside everything else; past 11 the zram device is full, and without systemd-oomd the 12th thread stalled the slice at MemoryHigh for over 4 minutes: nothing reached MemoryMax, nothing was killed.ManagedOOMSwap=kill(ranked by swap use, so the longest-idle session goes first) acted beforeManagedOOMMemoryPressure=killin every run, which avoided the inversion described above. When memory filled faster than oomd's window, the kernel's OOM killer still ended new sessions' programs during their first turn (7 in one run).Releasing idle no-native-resume sessions under memory pressure, or a setting for the 30-minute keep, would remove all of this on small machines.