Repository navigation
Description
Describe the bug
When the filesystem is sandbox-backed, the system prompt tells the model that the sandbox root is /workspace, and the filesystem tool's path normalizer strips exactly the /workspace prefix. Both values are hardcoded. They ignore the sandbox's actual workspace root, which comes from WorkspaceSpec.root and, for E2B, from E2bSandboxClientOptions.workspaceRoot (default /home/user).
As a result the model is told a directory that does not exist, and shell commands that use the advertised path fail.
To Reproduce
-
Build a
HarnessAgentwith an E2B sandbox:new E2bFilesystemSpec() .apiKey(...) .templateId(...) .workspaceRoot("/home/user")
-
Start a session and ask the model to run
pwdand thenecho hi > /workspace/x.txt. -
pwdreturns/home/user(correct, matching the client option), but writing to/workspacefails withPermission denied— the directory does not exist and the sandbox user is not root.
The prompt itself is visibly wrong: it contains Sandbox root: /workspace (container id: ...).
Where it comes from
-
agentscope-harness/.../middleware/WorkspaceContextMiddleware.java:368— hardcoded literal:sb.append("Sandbox root: /workspace (container id: ")
-
agentscope-harness/.../HarnessAgent.java:2708-2709— the path normalizer is also pinned to the constant:pathNormalizer = WorkspacePathNormalizer.of(ShellPathPolicy.SANDBOX_WORKSPACE_PREFIX);
-
agentscope-harness/.../skill/runtime/ShellPathPolicy.java:46—SANDBOX_WORKSPACE_PREFIX = "/workspace".
Meanwhile the filesystem layer reads the real root elsewhere:
agentscope-harness/.../filesystem/sandbox/SandboxBackedFilesystem.java:333-338—resolveWorkspaceRoot()readsstate.getWorkspaceSpec().getRoot().agentscope-extensions-sandbox-e2b/.../E2bSandboxClientOptions.java:46—workspaceRoot = "/home/user".
Why it is easy to hit
E2bFilesystemSpec exposes two independent setters with different defaults:
workspaceRoot(String)(line 73) →E2bSandboxClientOptions.workspaceRoot, default/home/userworkspaceSpec(WorkspaceSpec)(line 144) →WorkspaceSpec.root, default/workspace
Setting only the former (the natural choice, since it is the one that controls the E2B client) leaves the two roots disagreeing.
Expected behavior
The advertised sandbox root and the path normalizer prefix should be derived from the active workspace spec rather than hardcoded — e.g. the prompt can use sandbox.getState().getWorkspaceSpec().getRoot(), and HarnessAgent can build the normalizer from the configured spec (available at build time via the SandboxFilesystemSpec) instead of ShellPathPolicy.SANDBOX_WORKSPACE_PREFIX.
If deriving it is not feasible, exposing it as a configuration option would at least remove the hardcoded mismatch.
Environment
- agentscope-java 2.0.4
- E2B sandbox (Linux, non-root user), JDK 21
Activity
logicwu0 commentedon Oct 18, 2026
I would like to work on this. I checked main at 40a4a57 and added local offline regression tests: an active sandbox with WorkspaceSpec.root=/home/user still advertises /workspace; the default E2B configuration and an explicit workspaceRoot("/custom/workspace") both leave WorkspaceSpec.root at /workspace. The three new assertions fail, while the two existing sandbox-prompt tests pass. No model or E2B service was contacted.
Proposed scope:
One compatibility question before finalizing the E2B part: if callers explicitly set workspaceRoot(...) and workspaceSpec(...).root to different values, would you prefer rejecting that conflicting configuration, or preserving workspaceRoot(...) as authoritative and copying it into the effective WorkspaceSpec? I lean toward rejecting explicitly conflicting values instead of silently overriding one, but would like to confirm the intended contract. Existing persisted E2B state with differing roots also needs to retain the actual execution directory rather than be moved implicitly.
chcodex commentedon Oct 19, 2026
see #2194
fix(harness): honor active sandbox workspace roots (agentscope-ai#3646)