fix(server): one greedy agent process no longer takes down the whole server - #5788
Conversation
Agent tool calls run as children of the server, so they share the t3code.service cgroup. systemd defaults to OOMPolicy=stop, so when the kernel OOM-killed one greedy child it stopped the whole unit: server, every live agent, and the user's relay connection. Set OOMPolicy=continue. The kernel still reaps the greedy child, the server keeps running, and Restart=always still covers the main process. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
ApprovabilityVerdict: Approved 3cf0584 Adds a single systemd directive You can customize Macroscope's approvability policy. Learn more. |
## What's Changed * feat(web): project icons can be chosen manually by @t3dotgg in pingdotgg/t3code#5775 * fix(server): one greedy agent process no longer takes down the whole server by @t3dotgg in pingdotgg/t3code#5788 **Full Changelog**: pingdotgg/t3code@v0.0.33-nightly.20260809.1040...v0.0.33-nightly.20260809.1041 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.33-nightly.20260809.1041
Problem
My connection kept dropping with
Relay environment endpoint is unavailable: endpoint_request_failed, and it looked like a relay bug. It was not. The server was being killed and restarted underneath me.An agent was running memory-hungry python scripts in a worktree. Three times in one hour they grew past 50 GB and the kernel OOM killer reaped them. That part is fine and working as intended.
The problem is what happened next. Agent tool calls run as children of the server, so they live in the same
t3code.servicecgroup. systemd defaults toOOMPolicy=stop, which means killing any one process in a unit stops the entire unit. So one bad python script took down the server, every live agent, and my ssh sessions:cloudflared survives those restarts, so the tunnel stays up and points at a dead origin. The relay's mint-credential request then gets:
which maps to
EnvironmentMintRequestFailedand surfaces as the banner.Solution
Set
OOMPolicy=continueon the generated unit. The kernel still reaps the greedy child, but the server keeps running and nobody gets disconnected.Restart=alwaysstill covers the case where the main process itself dies.Existing installs heal themselves.
status.currentcompares the installed unit against the rendered one, so the next update rewrites it.Verification
vp test run apps/server/src/cloud/bootService.test.tspasses (7 tests).systemd-analyze verifyaccepts the rendered unit on systemd 259.apps/serveris clean.Written by Claude Opus 5 (1M context) in Claude Code, driven by Theo.
Note
Medium Risk
Changes long-running service supervision behavior on Linux; misconfiguration could leave a degraded server running after OOM, though scope is limited to the generated unit and existing restart policy.
Overview
Prevents a single OOM-killed agent child from stopping the whole
t3code.serviceunit.renderBootServiceUnitnow emitsOOMPolicy=continuein the generated systemd user unit. Agent tool processes share the server’s cgroup; with systemd’s defaultOOMPolicy=stop, the kernel reaping one memory-heavy child could tear down the server, other agents, and live sessions. The greedy process still dies; the main server keeps running, withRestart=alwaysunchanged for when the main process itself exits.A unit test asserts the rendered unit includes
OOMPolicy=continue. Installs that compare the on-disk unit to the rendered template pick up the change on the next repair/update.Reviewed by Cursor Bugbot for commit 3cf0584. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Prevent OOM-killed agent child processes from stopping the server
Adds
OOMPolicy=continueto the systemd unit generated byrenderBootServiceUnitin bootService.ts. This tells systemd to keep the parent service running when a child process is OOM-killed, rather than stopping the whole unit. A test is added to assert the directive is present in the generated unit.Macroscope summarized 3cf0584.