Skip to content
Source
Sign inSign up
pingdotgg/t3code

[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

Openshrikantkalar023(GitHub profile, opens in a new tab) opened this issue 0 comments

Summary

On a Linux host, one heavy agent can stall every other agent and every new provider start for hours. Two gaps cause it:

  1. An agent scope, and every background process in it, lives on after the session stops working. Nothing ends it until the server stops.
  2. New provider processes (codex app-server, claude) start inside the same shared agents slice. When that slice sits at MemoryHigh, 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.5385 as 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 MemoryHigh all that time. At stop it reported 10.0G memory peak, 7.6G memory swap peak. memory.max was never hit, and the kernel did not OOM-kill anything.
  • app-t3code.slice memory.events high = 225M. memory.pressure full 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-server scopes started 30 s apart. Each failed with Codex app-server did not answer initialize within 30 seconds after it had used about 1.5 s of CPU. A normal initialize on this host takes about 1 s.
  • Claude: 14 ClaudeMcpRegistrationTimeoutError timeouts, 5 min each, all in the swap-full window.
  • The main offender was one Claude scope. Its session started wrangler dev and 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 logged Failed to kill control group ... Invalid argument and Failed 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

  • MemoryHigh without 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 the memory.high penalty 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

  1. 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.
  2. 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.
  3. Smaller items:
    • Set a finite MemorySwapMax on the agents slice, so agents cannot fill all host swap.
    • Set MemoryHigh/MemoryMax on each scope, so one scope hits its own limit before the shared one.
    • Set ManagedOOMMemoryPressure=kill (and ManagedOOMSwap=kill) on the agents slice, so a stall ends with one kill instead of hours of throttling. With MemoryHigh alone, nothing ever kills the offender.

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=kill in a drop-in for app-t3code-agents.slice.
  • Cap each scope with a prefix drop-in, for example ~/.config/systemd/user/t3code-.scope.d/limits.conf with MemoryMax= and MemorySwapMax=.
  • After each server start, run systemctl --user set-property --runtime app-t3code-agents.slice MemoryHigh=infinity (from #39195), so the slice reaches MemoryMax and kills instead of throttling.
  • Look for stale scopes with systemctl --user list-units 't3code-*.scope' and systemd-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.
  1. tanstack-source added labelsbug

Sign in to join this conversation.