Skip to content

fix(e2b): honor WorkspaceSpec root and rebind remote snapshots - #4081

Merged
jujn merged 2 commits into
agentscope-ai:mainfrom
chcodex:fix/e2b-workspace-root-snapshot-rebind
Nov 11, 2026
Merged

jujn merged 2 commits into
agentscope-ai:mainfrom
chcodex:fix/e2b-workspace-root-snapshot-rebind

Conversation

@chcodex

@chcodex chcodex commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4080

Summary

This fixes two E2B sandbox defects on main:

  1. E2bSandboxClient ignored WorkspaceSpec.root, so E2bSandbox.doExec ran with the options default root (/home/user) instead of the configured workspace root. resume() also kept the stale persisted root, and volume coverage was computed from the wrong root.
  2. E2bSandboxClient did not override the two-argument deserializeState, so a deserialized RemoteSandboxSnapshot kept client == null and failed with RemoteSnapshotClient is not bound to snapshot id: ....

Changes

  • E2bSandboxClient.java
    • Resolve the effective root from WorkspaceSpec.root when non-blank, falling back to the merged options/state root.
    • Persist the effective root in create().
    • Synchronize the state root in resume() and recompute workspaceOnVolume from it.
    • Change isWorkspaceOnVolume to take the effective root plus mounts.
    • Override deserializeState(String, SandboxSnapshotSpec) to rebind RemoteSnapshotClient into a RemoteSandboxSnapshot, preserving the snapshot id (same pattern as Docker and Kubernetes).
  • Tests
    • Add E2bSandboxWorkspaceRootTest covering create, resume, and volume detection.
    • Add E2bSandboxClientRemoteSnapshotTest covering remote snapshot client rebinding.
    • Adjust E2bVolumeMountTest fixtures to match the new authoritative-spec-root semantics.

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=true

Result: Tests run: 67, Failures: 0, Errors: 0, Skipped: 0.

mvn -pl agentscope-extensions/agentscope-extensions-sandbox/agentscope-extensions-sandbox-e2b spotless:check passes.

Note: a full module test run also executes E2bVolumeMountLiveTest, which requires E2B_VOLUME_NAME; those 5 errors are pre-existing live-test environment gating and unrelated to this change.

Risk / compatibility

  • WorkspaceSpec.root becomes authoritative when set. Callers that previously relied on E2bSandboxClientOptions.workspaceRoot winning over a non-blank spec root will now use the spec root. This matches the documented WorkspaceSpec contract and the intended runtime behavior.
  • Remote snapshot rebinding only occurs when the caller supplies a RemoteSnapshotSpec; local/noop snapshot behavior is unchanged.

Merge order

  • Independent of the session-log / AG-UI PRs; no shared files, can merge at any time.

Resolve the effective workspace root from WorkspaceSpec when present, persist it on create, and synchronize it on resume so exec cwd and volume coverage use the configured root.

Override the two-argument deserializeState to rebind RemoteSnapshotClient into a deserialized RemoteSandboxSnapshot, matching Docker and Kubernetes.
chcodex added a commit to chcodex/agentscope-java that referenced this pull request Nov 9, 2026
@chcodex chcodex closed this Nov 9, 2026
@chcodex chcodex reopened this Nov 9, 2026
@jujn jujn added the P1 紧急不重要 label Nov 10, 2026
@jujn
jujn merged commit c887528 into agentscope-ai:main Nov 11, 2026
5 checks passed
chickenlj pushed a commit that referenced this pull request Nov 13, 2026
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 c887528)
Backport-review-patch: 59c40e0e42acfb64f103e5e1aa27f8fcfa0c3aa6
Constraint: No AgentScope Service or SDK migration
Confidence: high
Not-tested: Whole-repository verification pending after lane integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 紧急不重要

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] E2B sandbox ignores WorkspaceSpec.root and does not rebind RemoteSnapshotClient

2 participants