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
[Bug]:DockerSandbox.doExec() strips nested double quotes on Windows #2924
On Windows, DockerSandbox.doExec() fails for any shell command containing nested double quotes (e.g. mkdir -p "$(dirname ...)", python3 -c "..."). This breaks write_file and edit_file tools entirely.
Root cause: ProcessBuilder on Windows goes through cmd.exe /c, which strips inner double quotes from the sh -c argument. Linux/macOS are unaffected (no cmd.exe).
Root cause:DockerSandbox.doExec() passes the container command through the host process layer with no platform handling:
agentscope-harness/src/main/java/io/agentscope/harness/agent/sandbox/impl/docker/DockerSandbox.java:144-161 — builds ["docker","exec","-w",workspaceRoot,containerId,"sh","-c",command] and hands the List<String> straight to ProcessBuilder. A grep for os.name across the whole sandbox package tree returns zero matches.
On Windows the JDK joins that list into a single command line using the MSVCRT convention (inner " escaped as \"), and Docker Desktop's docker.cmd/docker.bat shim then routes it through cmd.exe /c, which does not understand \" and drops the inner quotes — so the sh -c payload arrives already mangled, producing exactly the Syntax error: end of file unexpected (expecting ")") you saw.
The payloads that break are generated by our own filesystem layer: BaseSandboxFilesystem.write() (:197-203) emits mkdir -p \"$(dirname …)\", and edit() (:258-281) emits python3 -c \"import sys, os, base64, json…\" — hence write_file and edit_file failing on every call.
Contrast: LocalFilesystemWithShell.java:334-338 already branches on os.name for cmd.exe vs sh -c; the Docker path never got the same treatment. Kubernetes / E2b / Daytona / AgentRun backends are unaffected (HTTP/API transports, no ProcessBuilder).
Impact: with DockerSandbox on a Windows host, file creation and editing are completely broken for any command containing nested double quotes. Severity: high.
Before we propose a fix — this issue already has three competing open PRs, and #2925 declares it is for this issue:
PR
Shape
Touches
Status
#2925fix(harness): preserve Docker exec commands on Windows (@guslegend0510)
platform-specific handling in doExec
DockerSandbox.java + new DockerSandboxExecTest.java
OPEN, non-draft, MERGEABLE
#2148fix(harness): stream Docker exec commands through stdin (@richuV)
option (1) below — docker exec -i … sh + write the script to stdin
DockerSandbox.java + new DockerSandboxCommandTest.java
option (2) below, applied at the BaseSandboxFilesystem call site only
BaseSandboxFilesystem.java + test
OPEN, non-draft, MERGEABLE
#2925 and #2148 edit the same method and will conflict with each other; #3084 is orthogonal (call-site encoding, does not fix write()'s mkdir -p \"$(dirname …)\" payload or any other future doExec caller).
Fix-direction recommendation for whoever consolidates: piping the script on stdin (the #2148 shape) is the only option that is correct on all hosts with no OS branch and no per-call-site encoding, since the command string then never traverses the host command-line parser at all:
Base64-wrapping (sh -c 'echo <b64> | base64 -d | sh', the technique edit() already uses at :254-256) is a viable fallback if stdin streaming is undesirable for interactive/timeouts reasons.
Because three open PRs already target this root cause, we are not filing a fourth — this window is for the maintainers to pick the seam. If you want us to contribute, the most useful non-duplicate action would be a host-side regression test that asserts the exact argv/stdin reaching docker exec on os.name=win, which none of the three currently proves end to end.
The only PR that declares this issue is #2925 (Fixes #2924, with a Docker verification that reproduces the reported command). #2148 targets a different issue — Closes #2135 — and is listed here only because it changes the same doExec call path to the stdin-pipe shape, so it collides with #2925 and is the concrete implementation of the recommended direction. #2925 is currently the greenest of the three (License, Module Sync, build (ubuntu-latest), build (windows-latest), codecov, CLA all pass) and is MERGEABLE; it is waiting on review, not on CI.
Nothing else in the evaluation changes, and we still are not filing a competing PR.
Activity
oss-maintainer commentedon Sep 13, 2026
Issue Evaluation
Category:
bug| Status: ConfirmedVerified against
main@39cd304a.Root cause:
DockerSandbox.doExec()passes the container command through the host process layer with no platform handling:agentscope-harness/src/main/java/io/agentscope/harness/agent/sandbox/impl/docker/DockerSandbox.java:144-161— builds["docker","exec","-w",workspaceRoot,containerId,"sh","-c",command]and hands theList<String>straight toProcessBuilder. A grep foros.nameacross the wholesandboxpackage tree returns zero matches."escaped as\"), and Docker Desktop'sdocker.cmd/docker.batshim then routes it throughcmd.exe /c, which does not understand\"and drops the inner quotes — so thesh -cpayload arrives already mangled, producing exactly theSyntax error: end of file unexpected (expecting ")")you saw.BaseSandboxFilesystem.write()(:197-203) emitsmkdir -p \"$(dirname …)\", andedit()(:258-281) emitspython3 -c \"import sys, os, base64, json…\"— hencewrite_fileandedit_filefailing on every call.LocalFilesystemWithShell.java:334-338already branches onos.nameforcmd.exevssh -c; the Docker path never got the same treatment. Kubernetes / E2b / Daytona / AgentRun backends are unaffected (HTTP/API transports, noProcessBuilder).Impact: with
DockerSandboxon a Windows host, file creation and editing are completely broken for any command containing nested double quotes. Severity: high.Before we propose a fix — this issue already has three competing open PRs, and #2925 declares it is for this issue:
fix(harness): preserve Docker exec commands on Windows(@guslegend0510)doExecDockerSandbox.java+ newDockerSandboxExecTest.javaMERGEABLEfix(harness): stream Docker exec commands through stdin(@richuV)docker exec -i … sh+ write the script to stdinDockerSandbox.java+ newDockerSandboxCommandTest.javamergeable=UNKNOWNfix(sandbox): use base64+stdin for edit() …(@gh-zhaoweifeng)BaseSandboxFilesystemcall site onlyBaseSandboxFilesystem.java+ testMERGEABLE#2925 and #2148 edit the same method and will conflict with each other; #3084 is orthogonal (call-site encoding, does not fix
write()'smkdir -p \"$(dirname …)\"payload or any other futuredoExeccaller).Fix-direction recommendation for whoever consolidates: piping the script on stdin (the #2148 shape) is the only option that is correct on all hosts with no OS branch and no per-call-site encoding, since the command string then never traverses the host command-line parser at all:
Base64-wrapping (
sh -c 'echo <b64> | base64 -d | sh', the techniqueedit()already uses at :254-256) is a viable fallback if stdin streaming is undesirable for interactive/timeouts reasons.Because three open PRs already target this root cause, we are not filing a fourth — this window is for the maintainers to pick the seam. If you want us to contribute, the most useful non-duplicate action would be a host-side regression test that asserts the exact argv/stdin reaching
docker execonos.name=win, which none of the three currently proves end to end.Automated evaluation by github-manager-bot
oss-maintainer commentedon Sep 13, 2026
One precision fix to the table above
The only PR that declares this issue is #2925 (
Fixes #2924, with a Docker verification that reproduces the reported command). #2148 targets a different issue —Closes #2135— and is listed here only because it changes the samedoExeccall path to the stdin-pipe shape, so it collides with #2925 and is the concrete implementation of the recommended direction. #2925 is currently the greenest of the three (License, Module Sync,build (ubuntu-latest),build (windows-latest), codecov, CLA all pass) and isMERGEABLE; it is waiting on review, not on CI.Nothing else in the evaluation changes, and we still are not filing a competing PR.
Automated by github-manager-bot