Skip to content

fix(harness): use real newlines in sandbox edit python -c - #2573

Open
jialiuyang wants to merge 2 commits into
agentscope-ai:mainfrom
jialiuyang:fix/sandbox-edit-python-newlines
Open

fix(harness): use real newlines in sandbox edit python -c#2573
jialiuyang wants to merge 2 commits into
agentscope-ai:mainfrom
jialiuyang:fix/sandbox-edit-python-newlines

Conversation

@jialiuyang

Copy link
Copy Markdown

AgentScope-Java Version

2.0.x (main)

Description

BaseSandboxFilesystem.edit() built the python3 -c program by joining lines with Java \"\\\\n\", which emits a literal backslash-n. On a POSIX sandbox shell that string is passed to Python unchanged and raises SyntaxError, so replaceAll=false (the default edit_file path) never touches the target file.

This change uses real newlines in the -c program and fails fast when execute returns a non-zero exit code, instead of reporting unexpected server response.

ls / glob printf escapes and jsonEscape are intentionally unchanged.

Fixes #2571

Checklist

  • Code has been formatted with mvn spotless:apply
  • Targeted tests passing (BaseSandboxFilesystemTest)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated — N/A
  • Code is ready for review

BaseSandboxFilesystem.edit() joined the python3 -c program with Java "\\n", which
emits a literal backslash-n. POSIX shells pass that through, so Python raises
SyntaxError before any file is touched. Use real newlines and surface non-zero
exit codes instead of "unexpected server response".

Fixes agentscope-ai#2571
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Raise patch coverage for the sandbox edit exit-code guard
(null exitCode, null output, and long stderr truncation).

@oss-maintainer oss-maintainer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This PR modifies 2 files with 161 lines of diff.

Observations

  • Files changed: 2
  • Test coverage: ✅ Tests included
  • CLA: ⚠️ Not signed / Unknown

Suggestions

  • Please ensure all public API changes are backward compatible
  • Consider adding unit tests for new logic paths

Automated review by github-manager-bot

@AgentScopeJavaBot AgentScopeJavaBot added bug Something isn't working area/harness agentscope-harness (test/runtime support) labels Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/harness agentscope-harness (test/runtime support) bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: BaseSandboxFilesystem.edit fails when replaceAll=false because the generated Python command contains literal \\n sequences`

3 participants