Repository navigation
Description
Environment
- Repository:
agentscope-ai/agentscope-java - Baseline:
upstream/mainat7d84cff02(2026-11-09) - Module:
agentscope-extensions/agentscope-extensions-sandbox/agentscope-extensions-sandbox-e2b
Bug 1: WorkspaceSpec.root is ignored by the E2B sandbox client
E2bSandboxClient.create(WorkspaceSpec, SandboxSnapshotSpec, E2bSandboxClientOptions) only uses E2bSandboxClientOptions.workspaceRoot (default /home/user) and never reads WorkspaceSpec.root.
Relevant code on main:
E2bSandboxClient#create(E2bSandboxClient.java:58)E2bSandboxClient#resume(E2bSandboxClient.java:90)E2bSandbox#doExecusesgetWorkspaceRoot()as the envd process cwd
As a result, if an application passes WorkspaceSpec.root=/root/workspace, shell commands still run with pwd == /home/user.
The same wrong root also affects:
resume(): a persistedE2bSandboxStatekeeps the oldworkspaceRoot(/home/user) even when the current spec points at/root/workspace.isWorkspaceOnVolume(): volume coverage is computed from the options root instead of the effective root, so a volume mounted at/root/workspaceis incorrectly reported as not covering the workspace.
Bug 2: RemoteSnapshotClient is not rebound on deserialization
SandboxClient defines a two-argument default method:
default SandboxState deserializeState(String json, SandboxSnapshotSpec snapshotSpec) {
return deserializeState(json);
}E2bSandboxClient does not override it, unlike DockerSandboxClient / KubernetesSandboxClient, and does not re-inject the runtime client into a deserialized RemoteSandboxSnapshot.
After a state round-trip, RemoteSandboxSnapshot.client == null, so isRestorable() / persist() fails with:
java.lang.IllegalStateException: RemoteSnapshotClient is not bound to snapshot id: snap-1
at ...RemoteSandboxSnapshot.requireClient(RemoteSandboxSnapshot.java:112)
Reproduction
New regression tests were added under agentscope-extensions-sandbox-e2b/src/test/java/io/agentscope/extensions/sandbox/e2b/:
E2bSandboxWorkspaceRootTestcreateUsesWorkspaceSpecRootOverOptionsDefaultresumeUsesWorkspaceSpecRootOverPersistedStateRootcreateMarksWorkspaceOnVolumeWhenSpecRootIsCoveredByMount
E2bSandboxClientRemoteSnapshotTestdeserializeStateRebindsRemoteSnapshotClient
Against 7d84cff02, all four fail:
expected: </root/workspace> but was: </home/user>
workspace root /root/workspace is covered by the configured volume mount
==> expected: <true> but was: <false>
Unexpected exception thrown: SandboxException$SnapshotException: Remote exists check failed
Caused by: java.lang.IllegalStateException: RemoteSnapshotClient is not bound to snapshot id: snap-1
Expected behavior
WorkspaceSpec.rootis authoritative when non-blank.create()persists the effective root;resume()synchronizes the state root and recomputesworkspaceOnVolumefrom that root.deserializeState(json, snapshotSpec)rebinds the currentRemoteSnapshotClientinto a deserializedRemoteSandboxSnapshot, preserving the persisted snapshot id.
Verification
mvn -pl agentscope-extensions/agentscope-extensions-sandbox/agentscope-extensions-sandbox-e2b \
test \
-Dtest=E2bSandboxWorkspaceRootTest,E2bSandboxClientRemoteSnapshotTest,E2bVolumeMountTest,E2bSandboxOptionsAndStateTest,E2bSandboxRecoveryTest,E2bSandboxEnvsTest,E2bEnvdSandboxUrlTest \
-DfailIfNoTests=false -Dcheckstyle.skip=true -Dspotless.check.skip=trueAfter the fix: Tests run: 67, Failures: 0, Errors: 0, spotless:check passes.
Activity
fix(e2b): honor WorkspaceSpec root and rebind remote snapshots (agent…