Skip to content

E2B Protocol Compatibility: Metadata, TTL, and Snapshot/Fork APIs #1331

Open

Description

@mini-cookie

I'm using OpenKruise Agent with Substrate as the backend to implement sandbox management following the E2B protocol. The core APIs are already functional, but there are a few issues I'd like to raise. I understand the Substrate project's current priority is to get the end-to-end path working first, then iterate on more advanced capabilities. That said, I'd like to surface some questions early on and hear how the team is thinking about these.

1. Actor-level metadata and lifecycle fields:
Support Metadata.Annotations and Metadata.Labels on Actors to enable user identity association. Additionally, support fields like timeout (TTL duration), timeout_action (expiry action: Pause / Delete), and expires_at (absolute expiry timestamp) to enable automatic suspension and termination based on TTL.

2. Snapshot and fork interfaces:
Support snapshot and fork APIs, with behavior aligned to the E2B protocol specification.

Related Issue in Substrate
#553 Support sandbox platforms running on Substrate

Activity

  1. ronlv10 commented on Aug 31, 2026

    @ronlv10
    Collaborator
    1. Snapshot and fork interfaces:
      Doesn't the snapshot API provide a mechanism for forking? It's not a single 'fork' API, but AFAIU, a higher level could implement a fork using this API.
      Something like:
    1. SuspendActor which produces a durable ActorSnapshot
    2. CreateActorSnapshotTag to give it a stable name
    3. CreateActor with Actor.source_snapshot_tag
    4. ResumeActor on the clone
  2. mini-cookie commented on Sep 1, 2026

    @mini-cookie
    Author

    Regarding the snapshot and fork interfaces: the parent sandbox is always resumed in-place. In the microVM scenario, this means the Cloud Hypervisor process should not exit. Benjamin Elder (@BenTheElder) Ron Lev (@ronlv10)

  3. BenTheElder commented on Sep 1, 2026

    @BenTheElder
    Collaborator

    Regarding the snapshot and fork interfaces: the parent sandbox is always resumed in-place.

    Why does it have to be in-place? Why can't it also resume from a snapshot?

  4. added
    kind/feature
    area/api
    on Sep 1, 2026
  5. mini-cookie commented on Sep 1, 2026

    @mini-cookie
    Author

    Benjamin Elder (@BenTheElder) Good question — I think there might be a slight misunderstanding about what I'm raising here. The concern isn't about how the child actor starts, but about what happens to the parent actor during the snapshot process.

    In E2B and other sandbox frameworks (AgentEnv、CubeSandbox, etc.), fork is a non-blocking operation on the parent sandbox. The parent keeps running its workload uninterrupted — you take a snapshot of its current state, and a new sandbox branches off from that point. The parent doesn't know or care that a fork happened.

    The flow Ron Lev (@ronlv10) described above (SuspendActor → snapshot → CreateActor → ResumeActor) requires suspending the parent first, which interrupts its execution. That's fundamentally different from E2B's fork semantics.

    In the microVM scenario specifically, the Cloud Hypervisor process should not exit. Taking a snapshot should be an internal operation within CH — pause vCPUs briefly, capture memory + device state, then immediately resume the vCPUs. The parent actor experiences only a microsecond-level vCPU hiccup, not a full suspend-resume lifecycle.

    So the real question is: can Substrate capture a snapshot of a running actor without transitioning it into a suspended state?

    The existing primitives (SuspendActor, CreateActorSnapshotTag, etc.) are useful as low-level building blocks for operations like migration and durable backup. But for E2B-compatible fork, we'd need a path where:

    1. The parent actor's vCPUs are paused momentarily (inside the VMM, not via SuspendActor)
    2. The snapshot is taken in-place
    3. The parent resumes immediately
    4. The child actor boots from the snapshot independently

    This way ForkActor(parent_id) becomes an atomic operation from the user's perspective, and the parent never leaves the running state.

  6. tomergee commented on Nov 14, 2026

    @tomergee
    Collaborator

    We hit item 1 from a second direction: ai-on-gke/sandboxenv-rl runs E2B SDK programs on Substrate
    actors, and three SDK features have nowhere to keep their data.

    What an Actor carries today (api/ateapi/v1/ateapi.proto, cf5768a0): metadata (atespace,
    name, uid, version, three timestamps), actor_template, worker_selector, source_tag, status.
    ListActorsRequest has an atespace and paging. A Worker already has labels, and
    UpdateWorkerRequest lets an update change them.

    What we need, smallest first:

    1. Labels on an Actor. A map<string, string> labels, set at create, changeable by
      UpdateActor, returned by GetActor and ListActors. Same shape and rules as Worker.labels.
      We use it for the caller's metadata (E2B metadata), and to group the actors of one run.
    2. A label filter on ListActors. Equality on a set of labels, like Selector.match_labels.
      Without it a caller that wants 20 actors of one run reads every actor of the atespace.
    3. An expiry on an Actor. expire_time, set at create and changeable, after which the control
      plane deletes the actor, also while it is suspended. This is E2B's timeout and set_timeout.
      A delete is all we need; a suspend-on-idle action (E2B Protocol Compatibility: Metadata, TTL, and Snapshot/Fork APIs #1331's timeout_action) is a separate
      request, and so is idle detection.

    1 and 2 are enough for us to stop keeping state outside Substrate. Until then we keep labels and
    deadlines in one Kubernetes object per actor next to our API server, and sweep expired actors from
    there. That works, but it is a second source of truth: each create is one more write to the
    Kubernetes API, and an actor and its object can disagree after a crash between the two writes.

    Questions:

    • Is 1 acceptable as an API direction, given that labels were removed from actor templates
      (Actor Template labels #1615)? If the objection was to labels as a selection mechanism, annotations (opaque, not
      selectable) would cover the metadata case, and 2 would then need another answer.
    • For 3, is a control-plane expiry something you want in ateapi, or do you see it as the job of
      the platform above Substrate?

    We can send a pull request for 1 if the direction is acceptable.

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/apikind/feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions