Repository navigation
Description
Issue: docker exec commands with double-quoted $(...) substitution break on Windows hosts — write_file/edit_file in sandbox always fail
Summary
When the agent runs inside a Docker sandbox on a Windows host (e.g. Windows 10/11 + Docker Desktop), write_file (and edit_file) fail with Failed to write file, even though the same sandbox works perfectly on Linux/macOS hosts.
Root cause: BaseSandboxFilesystem.write() builds a check command that contains a double-quoted command substitution:
if [ -e '<path>' ]; then echo 'EXISTS'; exit 1; fi; mkdir -p "$(dirname '<path>')" 2>&1On Windows, the docker CLI corrupts command arguments containing "$(...)" during argument passing (quoting is mangled before the container shell ever sees it). The container shell then reports Syntax error: end of file unexpected (exit code 2), so write() never reaches the success path and returns Failed to write file.
edit_file has the same problem — it builds python3 -c "..." with the whole Python script wrapped in double quotes.
Affected versions
Verified by decompiling io.agentscope.harness.agent.filesystem.sandbox.BaseSandboxFilesystem:
| Version | write check command | edit command | Fixed? |
|---|---|---|---|
| 2.0.3 | mkdir -p "$(dirname ...)" |
python3 -c "..." |
❌ |
| 2.0.4 | mkdir -p "$(dirname ...)" |
python3 -c "..." |
❌ |
| 2.1.0-BETA1 | mkdir -p "$(dirname ...)" |
python3 -c "..." |
❌ |
Steps to reproduce
- Windows host with Docker Desktop installed.
- Start the app with sandbox mode enabled (default).
- Call
write_filewith a path that does not exist yet (oredit_file). - Observe the failure:
Error: Failed to write file '<path>'.
Logs from the sandbox command (exit 2):
Syntax error: end of file unexpected
Expected behavior
write_file / edit_file should succeed inside the sandbox on Windows hosts, identical to Linux/macOS.
Verification notes (what we already tested)
- Removing the double quotes —
mkdir -p $(dirname '<path>')— works on both Windows and Linux hosts (same pattern already used bymove()). - A plain quoted variable reference
"$f"passes through fine; only double-quoted$(...)substitutions get corrupted. - We validated a base64-over-stdin variant for
edit_file(script shipped via heredoc,python3 -c 'import base64,sys;exec(base64.b64decode(sys.stdin.read()))'— single quotes only) and it works inside the sandbox: returns{"count": 1}.
Suggested fix
write(): drop the double quotes around$(dirname ...).edit(): avoid double quotes in the docker exec command entirely — e.g. ship the script as base64 over stdin as described above.- (Optional)
write()already has anuploadFilestransport added in 2.0.4; the check command blocks it with exit 2 before it can be used. Fixing the check command would unlock the cleaner upload path.
Environment
- OS: Windows 10/11 (host)
- Docker: Docker Desktop (Windows containers off, Linux containers)
- Java: JDK 17+ (backend runs Spring Boot / WebFlux)
- agentscope-harness: 2.0.3 / 2.0.4 / 2.1.0-BETA1 (confirmed identical bytecode for these methods)
Activity
fix(harness): avoid command substitution in sandbox write parent mkdir (
fix(harness): surface sandbox failure detail and fail closed on unkno…
fix(harness): surface sandbox failure detail and fail closed on unkno…
fix(harness): avoid command substitution in sandbox write parent mkdir (