Skip to content

[Feature]: E2B sandbox volumes support (mount existing volumes) #3155

Closed

Description

@chcodex

Is your feature request related to a problem? Please describe.

E2B offers persistent volumes that exist independently of sandbox lifecycles and can be mounted to sandboxes at custom paths (volumeMounts: [{name, path}] on POST /sandboxes). The current agentscope-extensions-sandbox-e2b module has no way to pass volume mounts: E2bPlatformHttp.createSandbox() only sends templateID + timeout, and there is no mount option on E2bSandboxClientOptions / E2bFilesystemSpec. So users who need cross-sandbox persistence on E2B must fall back to TAR persist/hydrate on every turn. (There is only an empty placeholder, mounts/E2bCloudBucketMountStrategy.)

Describe the solution you'd like

Support mounting pre-existing E2B volumes at sandbox creation time:

  1. New E2bVolumeMount POJO (name = existing volume name, path = absolute in-sandbox mount path, with validation + normalization).
  2. E2bSandboxClientOptions.volumeMounts (+ builder/fluent adders) and matching E2bFilesystemSpec.volumeMount(name, path) / volumeMounts(...) — same pattern as AgentRunFilesystemSpec.nasConfig/addOssMount, no harness-core changes.
  3. E2bPlatformHttp.createSandbox() serializes volumeMounts: [{name, path}] into POST /sandboxes (omit the field when empty); surface 400s (no beta access / unknown volume name) with the response body.
  4. Thread mounts through E2bSandboxClient.create() into E2bSandboxState.volumeMounts, and pass them on every creation path in E2bSandbox (ensureSandbox() new + connect-fallback recreate, restoreSandboxFromSnapshotTemplate()).
  5. Allow workspaceRoot to live on a volume mount (E2bSandboxState.workspaceOnVolume, computed as root.equals(mount) || root.startsWith(mount + "/"), mirroring AgentRunSandboxClient workspaceOnNas detection): when true, doPersistWorkspace() / doHydrateWorkspace() become no-ops and doDestroyWorkspace() skips rm -rf. When a mount point sits under workspaceRoot without covering it, exclude it from the TAR archive (same --exclude approach as WorkspaceMountSupport.tarExcludeArgsForBindMounts).
  6. Update E2bSandboxClient.copy()/merge() for the new field, keep E2bSandboxState JSON backward compatible, remove or implement the E2bCloudBucketMountStrategy placeholder.
  7. Tests: POST /sandboxes body assertion with mounts (MockWebServer), validation/normalization/workspaceOnVolume unit tests, options merge + serde round-trip, recovery with mounts.
  8. Docs: E2B section of docs/v2/en/docs/harness/filesystem.md plus a volume example.

References: E2B POST /sandboxes volumeMounts (SandboxVolumeMount{name, path}), https://docs.e2b.dev/volumes/mount, https://docs.e2b.dev/volumes.

Describe alternatives you've considered

  • New WorkspaceSpec entry subtype (e.g. VolumeMountEntry): more uniform across backends but requires harness-core WorkspaceEntry + Jackson changes; rejected in favor of the provider-options pattern already used by AgentRun NAS/OSS mounts.
  • Also wrapping Volume lifecycle APIs (POST/DELETE /volumes, Volume Content API read/write): out of scope for now; creation/management stays in E2B dashboard/SDK, this issue covers attach-at-create only.

Additional context

  • E2B Volumes are in private beta; behavior without access is a 400 from the platform, which should propagate clearly.
  • Open question for implementation: whether NATIVE_SNAPSHOT captures volume content — doc will recommend TAR + volume (or no-op persist) for the workspaceOnVolume case until verified.

Activity

  1. oss-maintainer commented on Sep 15, 2026

    @oss-maintainer
    Collaborator

    Issue Evaluation

    Category: enhancement | Status: Evaluated — feasible, provider-local, recommend proceeding

    Verified against main (97696a3a). Every factual claim in the report checks out, and the upstream API shape matches what is proposed.

    Codebase claims — confirmed

    • E2bPlatformHttp.java:54-57 — createSandbox(templateId, timeoutSeconds) puts only templateID + timeout; there is no mount parameter anywhere in the module.
    • E2bSandboxClientOptions.java:25-42 — no volume/mount field; E2bFilesystemSpec.java:33-103 — no corresponding fluent setter.
    • mounts/E2bCloudBucketMountStrategy.java is a genuinely empty placeholder (// intentionally empty — extend when wiring E2B volume mounts…), so item 6's "remove or implement" is a real cleanup, not new work.
    • E2bSandboxState.java:23-31 — no volume fields, confirming the persistence gap.
    • The creation paths named in item 4 are exactly the three that call createSandbox: E2bSandbox.java:173-177 (ensureSandbox() new), :191-196 (connect-failure recreate), :207-209 (restoreSandboxFromSnapshotTemplate()). Any mount plumbing has to reach all three or recovery silently loses the volume — the report is right to call this out explicitly.
    • Item 5's concern is real: doDestroyWorkspace() runs rm -rf <workspaceRoot> unconditionally (E2bSandbox.java:154-163), and doPersistWorkspace() TARs the root (:88-110). A volume-backed workspaceRoot would be both archived redundantly and deleted on destroy.
    • The precedent the design copies exists: AgentRunSandboxClient.java:85 + isWorkspaceUnderMounts (:146-162) set workspaceOnNas, and AgentRunSandbox.doPersistWorkspace() returns InputStream.nullInputStream() in that case (:133-137). Mirroring this for E2B is consistent with an established pattern in the repo rather than a new convention.

    Upstream API — confirmed
    E2B's public OpenAPI for POST /sandboxes defines NewSandbox.volumeMounts as an array of SandboxVolumeMount{ name, path } with both fields required — i.e. the array-of-objects body shape proposed in item 3, not the path-keyed map used by the JS/Python SDKs. Since this module speaks the platform REST API directly (apiBaseUrl = https://api.e2b.app), the report picked the correct spelling. Volume endpoints (/volumes list/create/get/delete) are also in the public API, and E2B publishes a "Volumes beta limitations" FAQ, which supports the private-beta caveat.

    Three refinements worth settling before implementation

    1. Prefer the report's matcher over AgentRun's. isWorkspaceUnderMounts uses a bare root.startsWith(mountDir), so /mnt/data-x would wrongly match a /mnt/data mount. The proposed root.equals(mount) || root.startsWith(mount + "/") is strictly correct — implement it as written, and consider it a bug worth back-filling in AgentRun separately rather than copying the weaker predicate. AgentRun also skips read-only mounts when deciding (!m.isReadOnly()); a read-only E2B volume must not qualify as a workspace host either.
    2. NATIVE_SNAPSHOT needs a definite answer, not a doc hedge. Because mounts are re-attached on restoreSandboxFromSnapshotTemplate() (item 4), volume content survives a snapshot restore by construction — but if the snapshot also captures volume content, restore-time duplication is the risk. Item 7's MockWebServer coverage cannot answer this; it needs one real-beta run. Suggested: land attach-at-create + workspaceOnVolume no-op first, and leave a TODO(volume-snapshot) in E2bPersistenceMode.NATIVE_SNAPSHOT javadoc until verified.
    3. State compatibility. E2bSandboxState is Jackson-registered via E2bHarnessSandboxJacksonModule; volumeMounts must default to empty and workspaceOnVolume to false when absent so already-persisted sessions still deserialize — that is the exact class of failure reported in [Bug]: Failed to deserialize Docker sandbox state #1584 for Docker sandbox state.

    Tradeoff on the rejected alternative. The WorkspaceSpec entry-subtype option is correctly rejected for now: WorkspaceMountSupport.tarExcludeArgsForBindMounts (agentscope-harness/.../WorkspaceMountSupport.java:66-78) already generates TAR --exclude args from BindMountEntry, and E2B already feeds it at E2bSandbox.java:102. A generic WorkspaceSpec volume entry would let every backend reuse that exclusion path — so if a second provider needs this, revisit option B rather than duplicating per-provider exclusion logic. Provider options keep the change out of agentscope-core today; the harness abstraction is the right call later.

    Scope / effort: medium — one module (agentscope-extensions-sandbox-e2b), 7 files + tests + docs, no harness-core change, no breaking API. Compatibility: additive; old serialized state must remain readable.

    The proposal as written is implementable and well-scoped. Maintainer input welcome on point 2 (beta access) before a PR is opened; if the shape is agreed, reply /approve and a fix proposal will be generated against items 1-6 with the tests described in item 7.


    Automated evaluation by github-manager-bot

  2. added
    enhancement
    area/extensions
    on Sep 15, 2026
  3. oss-maintainer commented on Sep 18, 2026

    @oss-maintainer
    Collaborator

    Status: 72 h feedback window expired — no automated PR will be generated, this proposal window here is closed

    The evaluation above went 72 hours (since 2026-09-15T10:13:53Z) without a /approve, /revise, or /reject reply, so per our workflow no competing PR will be filed from this proposal window and the window is closed. No action is needed from anyone.

    As of this check there is no open PR linked to this issue, so nothing is being retired here on account of a competing fix — the proposal simply timed out.

    The evaluation itself is unchanged and stays on the record as the starting point if this is picked up later: E2B volume-mount support is feasible and provider-local (agentscope-extensions-sandbox-e2b, ~7 files, additive API, no agentscope-core change), the NewSandbox.volumeMounts array-of-{name,path} shape matches E2B's public OpenAPI rather than the path-keyed map used by the JS/Python SDKs, and the three refinements named in the evaluation — the root.equals(mount) || root.startsWith(mount + "/") mount matcher (stronger than AgentRunSandboxClient.isWorkspaceUnderMounts' bare startsWith), a definite NATIVE_SNAPSHOT answer backed by one real-beta run, and defaulting volumeMounts/workspaceOnVolume in E2bSandboxState so already-persisted sessions still deserialize — are the parts worth carrying into any implementation.

    Point 2 of that evaluation (private-beta access needed to verify snapshot/volume interaction) is the reason this window was flagged for maintainer input rather than implemented directly. If a maintainer still wants an independent proposal here, reply on this issue and we will re-evaluate; a community PR claiming this work needs no coordination from us first.

    Automated feedback-window poll by github-manager-bot (HEARTBEAT §3, issue-to-pr Step 6). Posted 2026-09-18T10:25Z.

  4. added a commit that references this issue on Oct 22, 2026
    9730e81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/extensionsenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions