Skip to content

SSH and VS Code sessions disconnect under workspace memory pressure while the agent survives #30460

Closed as not planned

Description

@ericpaulsen

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:

  1. Session processes are preferred OOM victims. With CODER_PROC_PRIO_MGMT enabled, agent/agentexec/cli_linux.go sets oom_score_adj on spawned children before execve:

    • agent oom_score_adj < 0 → child gets 0
    • agent oom_score_adj >= 998 → child gets 1000
    • otherwise → child gets 998

    SSH sessions are launched via agentexec (s.Execer.PTYCommandContext in agent/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_SCORE can lower this, but because oom_score_adj is inherited, the same value also applies to every user workload started under the session.

  2. 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

  1. Increase (or make configurable) the Yamux write timeout as a first thing to test.
  2. Allow SSH/VS Code server processes to get a low OOM score without user workloads launched beneath them inheriting it.

Open questions for engineering

  1. 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?
  2. 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.
  3. 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

  1. linear-code commented on Oct 7, 2026

    @linear-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions