Repository navigation
Description
Summary
Under heavy memory pressure in a workspace, SSH and VS Code Remote sessions disconnect even though the Coder agent stays alive. Reported by a customer who protects the agent with the lowest oom_score_adj and uses victim-kill OOM (not memory.oom.group=1).
What we believe is happening
Two contributing causes, which may need different fixes:
-
Session processes are preferred OOM victims. With
CODER_PROC_PRIO_MGMTenabled,agent/agentexec/cli_linux.gosetsoom_score_adjon spawned children beforeexecve:- agent
oom_score_adj < 0→ child gets0 - agent
oom_score_adj >= 998→ child gets1000 - otherwise → child gets
998
SSH sessions are launched via agentexec (
s.Execer.PTYCommandContextinagent/agentssh/agentssh.go), so session shells and the VS Code server started inside them inherit a high score and are among the first OOM victims.CODER_PROC_OOM_SCOREcan lower this, but becauseoom_score_adjis inherited, the same value also applies to every user workload started under the session. - agent
-
Connections drop during memory stalls. In the same workspace and under the same pressure, a dedicated OpenSSH server stalls temporarily but recovers. Coder connections disconnect instead. This suggests a timeout/keepalive in our connection path gives up during a stall, independent of process kills.
Customer findings
| Test | Result |
|---|---|
| Agent in a dedicated cgroup, interactive-shell processes moved to a separate workload cgroup | Workload cgroup absorbs pressure; agent stays responsive; SSH and VS Code stay connected |
| Same, but workloads launched by IDE tasks, extensions, or non-interactive commands | Not covered; these bypass the interactive shell, so the workaround is incomplete |
| Dedicated OpenSSH server in the workspace | Stalls, then recovers without disconnecting |
Customer proposals
- Increase (or make configurable) the Yamux write timeout as a first thing to test.
- Allow SSH/VS Code server processes to get a low OOM score without user workloads launched beneath them inheriting it.
Open questions for engineering
- Which timeout actually terminates the session during a memory stall? Is Yamux on the SSH/Tailnet data path, or only on the agent ↔ coderd connection? If it's not on the session path, proposal 1 may target the wrong layer. Can the relevant timeout be made configurable?
- Is "protect session infrastructure, not workloads" feasible? One option: agent-managed cgroup v2 separation (agent + session processes in a protected cgroup, user workloads in another), which productizes the customer's workaround. Note that VS Code server spawns extension hosts/terminals itself, outside agentexec.
- Is this a bug or a feature request, and who owns it?
Diagnostics being collected
From a single incident, with timestamps: dmesg OOM kill logs, agent logs, coder ssh verbose logs, and VS Code Coder extension logs. These should distinguish "session process was killed" from "connection timed out".
This issue was generated by Coder Agents on behalf of @ericpaulsen.
Activity
linear-code commentedon Oct 7, 2026
ENG-3453