[Linux][CLI&UX] nemoclaw status does not show Error phase or rebuild hint after OOM kills dcode process inside sandbox
Description
When an OOM kill terminates a user process inside a LangChain Deep Agents Code sandbox, nemoclaw status continues to show Phase:Ready with no Error indication and no rebuild hint. The sandbox container supervisor survives the OOM event, so NemoClaw does not detect any failure — leaving users with no signal that their sandbox is degraded or that rebuild is the recovery action.
Environment
Device: Ubuntu 20.04 QEMU VM (4 GB RAM)
OS: Ubuntu 20.04.6 LTS
Kernel: 5.4.0-216-generic
Docker container memory limit: 256 MB
NemoClaw: v0.0.67
OpenClaw: deepagents-code 0.1.12
Steps to Reproduce
# Onboard with memory-limited container
nemoclaw onboard --agent langchain-deepagents-code --name dcode-oom --no-gpu
CONTAINER=$(docker ps | grep dcode-oom | awk '{print $1}')
docker update --memory 256m --memory-swap 256m $CONTAINER
# Connect and trigger OOM
nemoclaw dcode-oom connect
# Inside sandbox:
python3 -c "x=[]
while True:
x.append('X'*1000000)"
# Wait for "Killed"
# Check status
exit
nemoclaw dcode-oom status; echo "EXIT:$?"
# Try dcode
nemoclaw dcode-oom exec -- dcode -n "Reply RECOVERED."
Expected Result
Status reports Phase:Error or a degraded warning with OOM cause and rebuild hint:
Sandbox may be in a degraded state after an OOM kill.
Run `nemoclaw dcode-oom rebuild` to restore.
Actual Result
Status shows Phase:Ready with no indication of OOM:
Sandbox: dcode-oom
Phase: Ready
Inference: healthy
EXIT:0
Subsequent dcode call fails silently:
RuntimeError: Server process exited with code -9
After nemoclaw dcode-oom rebuild, sandbox recovers fully and dcode returns "RECOVERED".
Closing as completed by #5818, which added the bounded OOM health probe, degraded status, non-zero exit, rebuild guidance, and regression coverage in v0.0.69. This issue was reopened without a current-release reproduction; if it still reproduces on v0.0.81, please add the status output and reopen, and update NVB#6375705 separately.
[QA Verification] v0.0.93 — FAIL
Reproduced on NemoClaw v0.0.93 / OpenShell 0.0.85 / DGX Spark (aarch64, NVIDIA GB10, Ubuntu 24.04).
Steps:
- Onboard a
langchain-deepagents-codesandbox (dcode-sb) - Apply Docker memory limit:
docker update --memory 512m --memory-swap 512m <container> - Trigger OOM inside sandbox:
nemoclaw dcode-sb exec -- python3 -c "x = bytearray(600 * 1024 * 1024)" - Confirm OOM from host:
docker exec <cid> cat /sys/fs/cgroup/memory.events→oom_kill 1 - Check status:
nemoclaw dcode-sb statusandnemoclaw dcode-sb status --json
Result:
nemoclaw dcode-sb status → Phase: Ready, exit 0, no OOM indication, no rebuild hint.
nemoclaw dcode-sb status --json → terminalRuntimeHealth:
{
"kind": "unavailable",
"detail": "[SECURITY] Sandbox resource limits were NOT hardened for this shell.\nsh: 7: cannot open /sys/fs/cgroup/memory.events.local: Permission denied"
}
Root cause (unchanged from v0.0.69): The OOM health probe attempts to read /sys/fs/cgroup/memory.events.local from inside the sandbox, but the sandbox landlock policy blocks /sys/fs/cgroup access. The probe returns unavailable instead of degraded, so nemoclaw status continues to report Phase: Ready with exit 0 and no rebuild hint.
The fix from #5818 wired up the terminalRuntimeHealth field but did not move the cgroup probe to the host side — the probe still runs inside the sandbox where it cannot access cgroup data.
Picking this up.
Confirming the v0.0.93 verification against source on main (ab5411462, post-v0.0.95): the OOM probe still runs inside the sandbox, where the sandbox policy denies /sys/fs/cgroup.
probeTerminalRuntimeCgroupOom builds its command with buildOpenshellExecArgs (src/lib/actions/sandbox/terminal-runtime-health.ts:86), so CGROUP_OOM_PROBE_SCRIPT (terminal-runtime-health.ts:9-32) reads /sys/fs/cgroup/memory.events.local, memory.events, and the cgroup v1 memory.oom_control paths from inside the sandbox. Those reads are denied there — ci/platform-matrix.json:69 records that during physical validation "reads of /sys/fs/cgroup/cgroup.controllers ... remained denied", and the policies do not expose /sys.
The probe's failure path converts that denial into { kind: "unavailable" } (terminal-runtime-health.ts:92-97), and both status consumers escalate only on kind === "degraded" — the text hint at status-text.ts:218 and the non-zero exit at src/commands/sandbox/status.ts:41. So a real oom_kill is indistinguishable from "the probe could not run", and status stays Phase: Ready, exit 0, with no rebuild hint. That is the reported output, and it matches the terminalRuntimeHealth.detail in the verification above.
This is consistent with #5818's scope: it added the terminalRuntimeHealth field, the degraded rendering, and the non-zero exit, but left the probe on the in-sandbox transport, so the counter those three depend on was never readable on a policy-enforced sandbox.
Planned fix: read the counter from the host, where the sandbox container's memory cgroup is reachable, and keep unavailable strictly for "could not read". The call site is already injectable (status-snapshot.ts:414) and the probe only runs for terminal-runtime agents (status-snapshot.ts:412-415), so the change stays within terminal-runtime-health.ts and its tests.
One question before I build it. NemoClaw has a helper that resolves the gateway cluster container (getGatewayClusterContainerName, src/lib/onboard.ts:1211), but I have not found an equivalent that resolves a sandbox name to its own container for host-side inspection. If there is a supported mapping I should use, I would rather use it than add one. Otherwise I will propose deriving it through OpenShell.
I will confirm on a real OOM repro before opening a PR.
Answering my own question above, so it does not sit open: NemoClaw already has the sandbox-to-container mapping I was looking for, so I did not add one.
findLabeledSandboxContainers (src/lib/onboard/docker-driver-sandbox-recovery.ts:141) discovers containers by the OpenShell managed-by and sandbox-name labels, and resolveSandboxContainerOwner (src/lib/actions/sandbox/sandbox-container-owner.ts:23) applies the longest-owner rule that keeps my-assistant from claiming my-assistant-prod's container. startStoppedSandboxContainerForBackup already pairs them for host-side lifecycle work, so the probe now follows that same pattern.
PR: #7567.
One correction to my earlier comment, since it changes what a reviewer should look at: I described the fix as moving the probe "to the host side", which is right, but the reason the in-sandbox read fails is worth stating precisely. /sys is not masked at the container level — src/lib/onboard/initial-policy.ts grants scoped read-only sysfs paths, so /sys is present in the container. It is the OpenShell policy applied to the sandboxed process tree that denies /sys/fs/cgroup. A host-side docker exec is a fresh process outside that tree, which is why it can read the counter.
I verified the mechanism on real Docker: a memory-limited container whose child is OOM-killed keeps its supervisor running while /sys/fs/cgroup/memory.events goes oom_kill 0 to oom_kill 1, and docker exec reads it. That is the reported shape.
I could not run nemoclaw status end-to-end — this host has no OpenShell installation or registered sandbox — so the PR states that boundary rather than claiming a full verification. @lyral-commits, since you have the DGX Spark repro from the v0.0.93 verification, a check there would close the gap.