You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sandbox: bound subprocess output capture in run_process (apply #929 fix to sandbox exec path) #1016
sandbox/backends/base.py:run_process uses process.communicate() with no byte cap, so a sandboxed command emitting large output within the command_timeout window (e.g. yes) can exhaust the host process memory before the timeout fires. This is the same class as the already-fixed Agent OS Shell bug #929, which added a hard max_output_bytes cap with streaming — the sandbox exec path did not receive that treatment.
Mitigated by command_timeout and the container mem/pids limits, but output is not bounded by size. Apply a streaming byte cap consistent with the #929 fix.
I inspected the current implementation. run_process has no max_output_bytes parameter, unlike DirectShellExecutor. Should the cap be added as a keyword argument to run_process, sourced from SandboxConfig, or defined as a shared sandbox default?
I’ll match the existing _drain() and _decode() semantics from src/synapsekit/shell/executor.py once that API decision is confirmed.
Thanks for digging in. Do both: a max_output_bytes kwarg on run_process (sits next to timeout, defaulted) plus a matching SandboxConfig.max_output_bytes field that the exec path passes through. That mirrors how command_timeout already reaches run_process at docker.py:80. run_process is the low-level primitive and the version probes call it too, so it needs its own defaulted knob; the value people actually tune lives on the config. The one option I would skip is a shared module constant, since you can't override it per sandbox.
For the value: default 1_000_000 to line up with DirectShellExecutor, and validate > 0 in SandboxConfig.__post_init__ (same check the shell already does).
The actual fix is swapping process.communicate() for the streaming read in shell/executor.py::_drain — communicate() buffers the whole child output into memory before any limit applies, which is the bug. Read in chunks and kill the child as soon as either stream crosses the cap; keep the [output truncated] suffix from _decode so truncation is visible in the result. If you'd rather not copy _drain/_decode, lifting them into a small shared helper is welcome but not required — a local copy in base.py is fine.
Activity
Merge #940: sandboxed PC Twin (closes #747)
MohamedIdhries commentedon Sep 5, 2026
I inspected the current implementation. run_process has no max_output_bytes parameter, unlike DirectShellExecutor. Should the cap be added as a keyword argument to run_process, sourced from SandboxConfig, or defined as a shared sandbox default?
I’ll match the existing _drain() and _decode() semantics from src/synapsekit/shell/executor.py once that API decision is confirmed.
AmitoVrito commentedon Sep 8, 2026
Thanks for digging in. Do both: a
max_output_byteskwarg onrun_process(sits next totimeout, defaulted) plus a matchingSandboxConfig.max_output_bytesfield that the exec path passes through. That mirrors howcommand_timeoutalready reachesrun_processatdocker.py:80.run_processis the low-level primitive and the version probes call it too, so it needs its own defaulted knob; the value people actually tune lives on the config. The one option I would skip is a shared module constant, since you can't override it per sandbox.For the value: default
1_000_000to line up withDirectShellExecutor, and validate> 0inSandboxConfig.__post_init__(same check the shell already does).The actual fix is swapping
process.communicate()for the streaming read inshell/executor.py::_drain—communicate()buffers the whole child output into memory before any limit applies, which is the bug. Read in chunks and kill the child as soon as either stream crosses the cap; keep the[output truncated]suffix from_decodeso truncation is visible in the result. If you'd rather not copy_drain/_decode, lifting them into a small shared helper is welcome but not required — a local copy inbase.pyis fine.Ping me on the PR when it's up.
fix(sandbox): bound subprocess output capture in run_process (fixes S…
merge: bound sandbox subprocess output (SynapseKit#1028, fixes Synaps…
docs(changelog): record SynapseKit#1016 sandbox output-bound fix
Merge pull request SynapseKit#1036 from SynapseKit/integrate/sandbox-…