Repository navigation
fix(harness): avoid command substitution in sandbox write parent mkdir (#3850) - #3871
Merged
jujn merged 2 commits intoOct 31, 2026
Merged
Conversation
agentscope-ai#3850) The write() check command wrapped $(dirname ...) in double quotes. The docker CLI on Windows hosts mangles arguments carrying double-quoted command substitution before the container shell sees them, so write_file always failed with a shell syntax error. Dropping the quotes (as move() already does) would word-split parents containing spaces. Compute the parent directory in Java and pass it as a single-quoted literal instead: no command substitution, no double quotes, and space-safe parent creation on every host.
jujn
approved these changes
Oct 31, 2026
aMetric
added a commit
to aMetric/agentscope-java
that referenced
this pull request
Nov 2, 2026
…wn exit codes The quoted-space command fix for agentscope-ai#3262 / agentscope-ai#3850 is already on `main` (agentscope-ai#3871), so this branch now carries only the half that is still missing: what the model is told when a sandbox filesystem mutation fails. - `write()`, `move()` and `delete()` now append the sandbox's own diagnostic to the failure message. Before this, `write()` returned a bare `Failed to write file '<path>'` and `move()`/`delete()` embedded the raw stdout/stderr verbatim. - Raw output is clamped to 500 chars keeping the tail, where shells put the actual error line after a command's preamble. The cut backs off one char when it lands on a low surrogate so the JSON sent to the model never carries a lone surrogate. - Mutations fail closed when `execute()` reports no exit status. `exitCode()` is an `Integer`, so the previous `result.exitCode() != 0` unboxed a null and threw NPE in `move()`/`delete()`, while `write()` treated a null status as success and went on to upload. - `executeFailureMessage()` shares the same detail path, so `ls`/`read`/`edit`/`grep`/ `glob` inherit the clamp and the explicit `no exit status reported` wording. Tests: 7 new cases in `BaseSandboxFilesystemTest` (detail carried, clamp, null output, null exit code for write/move/delete) plus a regression guard asserting no double-quoted span containing a space is ever generated for `write()` or `move()`. Full `agentscope-harness` suite: 1601 tests, 0 failures, 37 skipped (Linux/Docker-only).
aMetric
added a commit
to aMetric/agentscope-java
that referenced
this pull request
Nov 2, 2026
…wn exit codes The quoted-space command fix for agentscope-ai#3262 / agentscope-ai#3850 is already on `main` (agentscope-ai#3871), so this branch now carries only the half that is still missing: what the model is told when a sandbox filesystem mutation fails. - `write()`, `move()` and `delete()` now append the sandbox's own diagnostic to the failure message. Before this, `write()` returned a bare `Failed to write file '<path>'` and `move()`/`delete()` embedded the raw stdout/stderr verbatim. - Raw output is clamped to 500 chars keeping the tail, where shells put the actual error line after a command's preamble. The cut backs off one char when it lands on a low surrogate so the JSON sent to the model never carries a lone surrogate. - Mutations fail closed when `execute()` reports no exit status. `exitCode()` is an `Integer`, so the previous `result.exitCode() != 0` unboxed a null and threw NPE in `move()`/`delete()`, while `write()` treated a null status as success and went on to upload. - `executeFailureMessage()` shares the same detail path, so `ls`/`read`/`edit`/`grep`/ `glob` inherit the clamp and the explicit `no exit status reported` wording. Tests: 7 new cases in `BaseSandboxFilesystemTest` (detail carried, clamp, null output, null exit code for write/move/delete) plus a regression guard asserting no double-quoted span containing a space is ever generated for `write()` or `move()`. Full `agentscope-harness` suite: 1601 tests, 0 failures, 37 skipped (Linux/Docker-only).
chickenlj
pushed a commit
that referenced
this pull request
Nov 13, 2026
#3850) (#3871) Backport the verified fix to the 2.0.x implementation and retain its existing public contracts where the upstream kernel differs. (cherry picked from commit e190a8d) Backport-review-patch: 12a2c43163f341d54051ed15a416418ee7b1d830 Constraint: No AgentScope Service or SDK migration Confidence: high Not-tested: Whole-repository verification pending after lane integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
2.1.0-SNAPSHOT (main @ 1524b31)
Description
Fixes #3850: on Windows hosts,
write_filein a Docker sandbox always fails withFailed to write file, becauseBaseSandboxFilesystem.write()builds its check command with a double-quoted command substitution:The docker CLI on Windows mangles arguments carrying
"...$(...)..."before the container shell sees them, so the shell reportsSyntax error: end of file unexpected(exit 2) andwrite()never reaches its success path.Change
Compute the parent directory in Java and pass it to
mkdir -pas a single-quoted literal:The generated command now contains no
$(...)and no double quotes at all, so this class of Windows-host argument mangling cannot recur.Why not simply drop the double quotes (the workaround verified in the issue)? An unquoted
$(dirname ...)word-splits its output, so parents containing spaces would break on every host — a regression, since paths with spaces are first-class in this codebase (see the existingit's a file.txtheredoc tests). The Java-side parent keeps space-safe quoting and is unit-testable without Docker.Note: the
edit_filehalf of #3850 (python3 -c "...") was already fixed on main by the heredoc-based edit script; only thewrite()check command remained affected.How to test
mvn -T1C -pl agentscope-harness -am test— 1590 tests, 0 failures/errorsBaseSandboxFilesystemTestassert the write check command carries no double quotes and no command substitution, that a parent with spaces is created via a single-quoted literal, and that root-level files skip the mkdir segmentwrite()against a real shell with spaces in the path, plus the existing-file rejection pathshwith a space-containing parentChecklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test— agentscope-harness module: 1590 tests, 0 failures, 0 errors)