Debugging OpenSandbox Sandboxes
Companion to OpenSandbox Best Practices. That
page says what to configure; this one says how to check what you actually got. Everything in the
first two sections runs inside the sandbox through sandbox.exec() (or a bash tool call in the
agent) — no cluster access needed. Sandboxes run on cgroup v2 with /sys/fs/cgroup mounted
read-only, so the files below are always readable.
What am I getting? The enforced limits
If cpu.max says 4 CPUs but nproc says 192, this cluster does not overlay CPU counts and the
host-core fan-out trap
applies.
How much am I using?
Throttling ratio = throttled_usec / (usage_usec + throttled_usec). A few percent means the CPU
limit is binding; above ~30% your commands are running dramatically slower than they look.
Did I hit the ceiling?
memory.peak == memory.max with a large max count means you are living at the ceiling even if
nothing has died yet. An oom_kill count that increased during the command means a process in the
cgroup was OOM-killed; a nonzero count alone may describe an earlier command.
If the whole sandbox died you will not get to read this file — see
detecting OOM from the client.
One-shot snapshot for the end of a rollout
Capture this into your rollout record and you can size limits from real peaks across a whole run instead of from one failure message.
Detecting OOM from the client
An OOM has one of two shapes, depending on what the kernel killed.
A child process died, the sandbox survived
From the client this is an ordinary command failure:
exec()returns normally withreturn_code == 137(or-9), usuallyKilledin stderr and truncated output.- Check whether
memory.events’soom_killcounter increased during the command. A nonzero historical count or highmemory.peakalone does not establish this command’s cause. - The sandbox can remain usable. Check partial command effects before rerunning a smaller step.
The whole sandbox died
When an OOM kill terminates the whole sandbox container, its exec daemon also stops. The next command request cannot reach it, and an attached PTY can lose its connection. Those symptoms also occur for other reasons, such as node loss or sandbox expiry.
On command execution failure or PTY loss, Gym checks the sandbox’s lifecycle status within the remaining
diagnostic budget. A terminal lifecycle OOMKilled reason alone does not identify the affected container.
Gym confirms OOM when the control-plane response identifies the current sandbox and contains the recognized
single-pod report of its sandbox container terminating with OOMKilled. The report must describe the
current container state; sidecars, init containers, historical states and ambiguous reports do not qualify.
A confirmed OOM becomes a provider_oom_killed event. Its diagnostic reason retains the evidence source
and any reported container exit code. details.exit_code stays unset because the command’s own exit was not observed.
The controller can retain this report after the pod disappears, so a later pod lookup returning 404 does not
erase the recorded cause. Command-status HTTP 410 bodies alone never establish OOM: even through the server
proxy, a response body can originate in the sandbox’s exec daemon.
If the lifecycle report is unrecognized, the optional inspect fallback below may provide evidence.
Without either source, Gym retains the observed request or command-outcome failure. A confirmed stopped or
failed sandbox without OOM evidence is provider_unavailable, retaining the original request failure as its cause.
The caller’s outcome policy chooses retries, scoring and health attribution from that evidence and the execution stage.
See Failure reporting and recovery for timeout and retry settings,
and Error Handling for the shared contract.
Inspect fallback
diagnostics.inspect_oom defaults to false. Enable it only for a deployment with the OpenSandbox 1.1.0
plain-text /sandboxes/{id}/diagnostics/inspect format. This deprecated endpoint is a compatibility fallback,
not a supported structured API: Kubernetes requires the unique sandbox container’s current State to be
Terminated (..., reason=OOMKilled); Docker requires one container, Running: False and OOMKilled: True.
Unknown layouts, duplicate states, failed requests and bodies over 64 KiB provide no OOM evidence.
Lifecycle reads and optional inspect requests share the remaining diagnostic/recovery budget. A failed diagnostic lookup cannot replace the original failure. Confirm support with the deployment operator before enabling this route.
Lifecycle report compatibility
Gym recognizes the control-plane status shape state="Failed", reason="FAILED" with a matching sandbox ID
and the complete 1/1 observed pods failed report naming its <sandbox-id>-0 pod and sandbox container.
This compatibility parser is deliberately narrow: pooled pods, multiple pods, mismatched IDs, extra termination
text and unknown report layouts provide no OOM evidence. A generic FAILED or OOMKilled reason is insufficient.
Recognition uses the existing bounded lifecycle lookup; no additional option or request is required.
Counting OOMs across a run
Use the saved reports described in Failure observations.
Count each event ID with kind provider_oom_killed once, grouping by task ID to locate repeated OOMs.
Exit code 137 alone does not confirm OOM; counting a failure does not choose its score or health outcome.
Cluster-side checks
If you have kubectl access to the sandbox namespace. The pod name is the sandbox id the SDK
returned with -0 appended; sandboxes also carry the opensandbox.io/id label.
The resources jsonpath is the fastest way to confirm you did not accidentally set the same map
for requests and limits.