agentscope-ai / agentscope-ai/agentscope-java

[Bug]:BaseSandboxFilesystem.edit() generates broken python3 -c command with literal \n

Ouverte
#1,609 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
area/harness bug
Langage dominant
Java
Étoiles
5.6k
Forks
1.3k
Merge moyen
4 j 12 h
PR mergées (30 j)
77

Description

Description

BaseSandboxFilesystem.edit() generates python3 -c "...code..." shell 命令,Python 语句之间用字面两字符 \n 分隔。但 shell 双引号不会把 \n 解释为换行,导致 Python 收到单行代码 → SyntaxError。

Steps to Reproduce

1. 使用 SandboxBackedFilesystem 配合远程沙箱(Aone / E2B 等)
2. 调用 edit(ctx, path, oldString, newString, false)
3. 框架生成类似:
python3 -c "import pathlib\npath = pathlib.Path('/home/user/workspace/foo.txt')\n..."
4. 沙箱 shell 执行 → Python 收到单行 → SyntaxError

Expected Behavior

edit 操作应成功。建议的修复方式:不走 exec,改为:
1. 通过沙箱 file API 读取文件内容
2. Java 侧完成字符串替换
3. 通过沙箱 file API 写回

Environment

- agentscope version: 2.0.0-RC1
- Sandbox: Aone remote sandbox
- Java: 21

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.