Skip to content

Modal sandbox: evaluate native filesystem APIs and clarify overwrite compatibility #5088

Description

@Filimoa

Describe the feature

Consider adopting Modal's native sandbox.filesystem API for sandbox file transfers, with an explicit decision on overwrite compatibility. The Modal provider currently transfers files through shell commands. The native API could reduce transfer overhead, but live testing found behavior differences that prevent a straightforward replacement.

Observed compatibility differences

Tests against Modal 1.4.3 and 1.5.4 found:

Operation Current shell writes Native write_bytes
Write through a symlink Updates the target Replaces the symlink; target remains unchanged
Overwrite a hard-linked file Updates contents visible through both links Replaces the destination inode; other links retain old contents
Overwrite an existing 0640 file Preserves permissions Resulting permissions were 0644

Modal also documents a 5 GB read limit for its filesystem API. That needs consideration before replacing shell-based reads.

The investigation inspected Agents SDK v0.22.3, where shell transfers were still in use. Both tested Modal versions support the native APIs.

Preliminary performance results

Same-container measurements, retaining SDK path validation, with six alternating observations per method:

Modal version Median write: shell → native Median read: shell → native
1.4.3 0.459s → 0.407s 0.342s → 0.328s
1.5.4 0.690s → 0.528s 0.584s → 0.511s

These are small-sample file-operation measurements, not sandbox startup measurements. Binary round trips exceeding 8 MiB also passed.

Decision requested

Would maintainers prefer to preserve the current in-place write semantics, or explicitly adopt replacement semantics for the Modal provider?

Before implementing this, it would help to establish:

  • Whether the observed symlink, hard-link, and permission behavior is intentional and supported by Modal.
  • Which overwrite semantics the Agents SDK intends to guarantee across providers.
  • Whether native reads can be adopted independently without introducing a size-limit regression.

A stat-before-write fallback would need careful treatment: another sandbox process could change the destination between inspection and writing.

Any implementation should retain remote path validation, read-only grants, explicit-user access checks, SDK error categories, cancellation behavior, and avoid retrying ambiguous writes.

Modal's deprecation guidance concerns the older Sandbox.open/FileIO APIs; the SDK's existing shell-based transport is not using those deprecated APIs.

References: Modal filesystem API, migration guidance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions