Repository navigation
feat(sandbox): attribute OOM kills and retry out-of-memory runs after a pause - #4633
Merged
Merged
Conversation
runnerd reads the session cgroup's oom_kill count (memory.events, the whole subtree) as an exec starts and as it ends. An exec that died of a SIGKILL (exit 137) no cancel, deadline or stall watch sent, while that count rose, carries oomKilled: true on its exit event; another exec's OOM kill does not turn an ordinary failure into one. The exit also carries the session's memory.peak where the kernel reports it, and /healthz reports the session's memory: in use, limit, peak and OOM kills. Both runnerd protocol copies take the fields as additive.
The spawner forwards runnerd's oomKilled as the OOM_KILLED error code, with the session's peak in the message. When an exec's stream ends with no exit because its container died, the eviction check now runs before the result is sent, and the inspect it already makes reads State.OOMKilled as well: a container Docker recorded as OOM-killed ends the exec as SESSION_OOM instead of SESSION_LOST. Kubernetes restarts an OOM-killed runner in its Pod, so it keeps SESSION_LOST.
A turn whose exec result reads OOM_KILLED or SESSION_OOM settles with the new resource_exhausted code and a reason naming the memory limit, on the task and automation hosts. It is retried, but not at once: the task retry and the automation re-kick wait 2, 10, then 30 minutes by attempt, since an immediate retry would meet the same limit. The task card shows an out-of-memory sentence (EN/DE/FR); the run's public automation code stays turn_crashed.
This was referenced Oct 9, 2026
This was referenced Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Item 3 of the run guards, which the owner approved: say when the sandbox's memory limit ended an agent, and stop retrying it at once.
runnerd. The exec manager reads the session cgroup's
oom_killcount (memory.events, which covers the whole subtree) when an exec starts and again when it ends.exitevent then carriesoomKilled: true. Another exec's OOM kill does not turn an ordinary failure into one.memory.peakwhere the kernel reports it./healthzreports the session'smemory: current, limit, peak and OOM kills.Spawner. runnerd's
oomKilledbecomes theOOM_KILLEDerror code. When a stream ends without an exit because the container died, the eviction check now runs before the result is sent, and the inspect it already makes also readsState.OOMKilled(no extra fork). A container Docker recorded as OOM-killed ends the exec asSESSION_OOMinstead ofSESSION_LOST. Kubernetes restarts an OOM-killed runner inside its Pod, so it keepsSESSION_LOST.Platform.
OOM_KILLEDandSESSION_OOMsettle the turn with the newresource_exhaustedcode and a reason naming the memory limit.out_of_memorysentence (EN/DE/FR), and the inbox body falls back to the generic one.Run.failureCodestaysturn_crashed, so the OpenAPI enum doesn't move.Tests
exec-manager.stall.test.ts(OOM attribution: a kill with a rise, no rise, a plain failure, unreadable counts) andsession-memory.test.ts(readingmemory.eventsand the peak).session-routes.test.ts(OOM_KILLEDwith the peak; a dead container read asSESSION_OOMorSESSION_LOST, evicted before the result) anddocker-session-backend.test.ts(OOMKilled read from the same inspect, once per incarnation).*.sandbox_endedsuites, the retry delays, the i18n message tests and the legacy guard. Type-checks for runtime, spawner and platform are clean.startAfterMswiring infailAgentRunFromTurn. It is DB-bound and belongs to the backend integration lane.