[Bug]: Agent slice MemoryMax at 75% of RAM can hang/reboot a 16 GiB laptop before the slice kill path saves the session #47050
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/desktop
Steps to reproduce#
- Linux desktop laptop, ~16 GiB RAM, swap present, no
systemd-oomd/earlyoom. - Start T3 Code (desktop). Confirm
app-t3code-agents.sliceis set withsystemctl --user set-property --runtimetoMemoryHigh = max(RAM − 6GiB, RAM / 2)andMemoryMax = max(RAM − 4GiB, 75% RAM)(on this host ~9.2G / ~11.4G). - Run an OpenCode agent whose child (
nix.localhere) grows toward ~8 GiB RSS, still under thatMemoryMax. - Leave a Wayland session running (kwin + Intel iGPU unified memory).
agentSliceMemoryLimits() in the desktop asar (same formula as apps/server process/agentScope.ts) is:
high: hasSwap ? Math.max(totalBytes - 6 * GiB, Math.floor(totalBytes / 2)) : "infinity",
max: Math.max(totalBytes - 4 * GiB, Math.floor(totalBytes * .75))
There is no user setting. T3 reapplies this on start and on memory change.
Expected behavior#
The agent slice cap is low enough that a runaway agent is killed inside app-t3code-agents.slice while kwin / plasmashell still have reclaimable RAM. The desktop session stays up. Global OOM does not run.
Actual behavior#
On this 16 GiB host T3 set MemoryMax=12205916160 (75% of MemTotal). nix.local in t3code-opencode-*.scope reached ~8.1 GiB anon RSS (oom_score_adj=800) and was globally OOM-killed at 2026-12-01 11:06:52. The slice MemoryMax never tripped.
At kill time the kernel reported ~114 MiB free RAM, 124 kiB free of 15 GiB swap, all_unreclaimable? yes, and gpu_active≈32.5 GiB with gpu_reclaim=0 (Intel Lunar Lake xe). Fifty seconds earlier kwin logged atomic commit failed: Device or resource busy. panic_on_oom=0, so OOM itself did not reboot.
Userspace then went quiet (only tailscaled kept logging). Journal ended 11:08:22 with no systemd shutdown. Next boot 11:09:02 renamed both journals as uncleanly shut down and printed BERT: Skipped 1 error records. That is a hang plus a hard reset, not a clean reboot.
Same nix OOM-kills on 2026-11-24 did not take the machine down. This time GPU/desktop reclaim was already stuck, so killing the agent was too late.
This is not a duplicate of:
- #43662 — agents stall at
MemoryHighbecause the cgroup cannot use swap (memory.swap.max=0). Nothing is killed; the host stays up. - #46836 — one heavy agent sits at
MemoryHighand throttles the whole slice / new providers.MemoryMaxis never hit; the host stays up.
Here MemoryMax is simply too high for a 16 GiB laptop, so the host OOM path runs first and the session dies.
Impact#
Blocks work completely
Version or commit#
t3code 0.1.13 (desktop Beta, /opt/T3 Code (Beta))
Environment#
- Ubuntu (kernel
7.0.0-38-genericon the crashing boot, now7.0.0-44-generic) - KDE Plasma / kwin_wayland
- Samsung 940XHA (Lunar Lake,
xeiGPU), 16 GiB RAM - zram + disk swap (~15 GiB total)
- systemd user manager, cgroup v2
- no
systemd-oomdorearlyoom
Logs or stack traces#
Dec 01 11:06:02 kwin_wayland: kwin_wayland_drm: atomic commit failed: Device or resource busy
Dec 01 11:06:52 kernel: gmain invoked oom-killer: gfp_mask=0x140cca(...), oom_score_adj=200
Dec 01 11:06:52 kernel: all_unreclaimable? yes ... gpu_active:34072884kB gpu_reclaim:0kB
Dec 01 11:06:52 kernel: Free swap = 124kB
Dec 01 11:06:52 kernel: Total swap = 15759352kB
Dec 01 11:06:52 kernel: oom-kill:constraint=CONSTRAINT_NONE,...task_memcg=.../app-t3code-agents.slice/t3code-opencode-312f399e.scope,task=nix.local,pid=407614
Dec 01 11:06:52 kernel: Out of memory: Killed process 407614 (nix.local) total-vm:18837388kB, anon-rss:8470272kB, ... oom_score_adj:800
Dec 01 11:06:52 systemd: t3code-opencode-312f399e.scope: The kernel OOM killer killed some processes in this unit.
# journal then only tailscaled until 11:08:22; next boot 11:09:02
Dec 01 11:09:02 systemd-journald: File .../system.journal corrupted or uncleanly shut down, renaming and replacing.
Dec 01 11:09:02 kernel: BERT: [Hardware Error]: Skipped 1 error records
Workaround#
A user systemd path unit that watches T3's runtime drop-in and re-applies MemoryHigh=6G MemoryMax=8G on app-t3code-agents.slice whenever T3 overwrites it with the 75% formula.
tanstack-source added labelsbug
Sign in to join this conversation.