Add E2B terminal backend (create + attach modes) - #90226
Closed
VCoder25 wants to merge 1 commit into
Closed
Conversation
New tools/environments/e2b.py implementing BaseEnvironment via the E2B Python SDK (modeled on the Daytona backend), plus wiring: TERMINAL_ENV=e2b, TERMINAL_E2B_TEMPLATE / TERMINAL_E2B_SANDBOX_ID / TERMINAL_E2B_TTL_SECONDS, lazy_deps entry (e2b==2.40.0), env_probe remote-backend registration, and a guarded check_terminal_requirements branch. Design notes: - Sliding absolute TTL: E2B's timeout is an absolute expiry (not an idle window), so it is renewed via set_timeout() before every command. - Non-destructive cancel: the base class fires cancel_fn on every per-command timeout; killing the sandbox there would turn one slow command into a dead session, so cancel only logs and the SDK's own command timeout terminates the remote process. - Attach mode (TERMINAL_E2B_SANDBOX_ID) connects to an externally owned sandbox via Sandbox.connect() and never kills it on cleanup — for orchestrators that own sandbox lifecycle. - Create mode fails closed on an empty template. Battle-tested in production at Vugola (video-editing agent jobs).
Collaborator
Duplicate of #18348. That open PR already implements the E2B terminal backend, including the same environment and terminal wiring, with broader lifecycle/configuration/test coverage. |
Author
|
Closing — duplicate of #18348. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an
e2bterminal backend so Hermes can use E2B sandboxes as its computer, alongside the existing modal/daytona/vercel cloud backends.What's included
tools/environments/e2b.py—E2BEnvironmentimplementingBaseEnvironment, modeled closely on the Daytona backend (_ThreadedProcessHandleover blocking SDK calls, heredoc stdin mode).TERMINAL_ENV=e2b,TERMINAL_E2B_TEMPLATE,TERMINAL_E2B_SANDBOX_ID,TERMINAL_E2B_TTL_SECONDS;lazy_depsentry (e2b==2.40.0);env_proberemote-backend registration; a guardedcheck_terminal_requirementsbranch (missing SDK → clear log +False, not a crash).Design decisions (learned the hard way, live-tested)
timeoutis an absolute expiry, unlike an idle reaper — so it's renewed viaset_timeout()before every command; long agent turns can't lose their computer.BaseEnvironmentfirescancel_fnon every per-command timeout; killing the sandbox there turns one slow command into a dead session (every later command failing on a vanished sandbox). Cancel logs; the SDK's own command timeout terminates the remote process; the sandbox survives.TERMINAL_E2B_SANDBOX_IDconnects to an externally owned sandbox viaSandbox.connect()and never kills it on cleanup — for outer orchestrators that own sandbox lifecycle (create mode still kills its own).Provenance
Running in production at Vugola powering agentic video-edit jobs (the harness drives ffmpeg work inside per-job E2B sandboxes, headless via
hermes -z). Happy to adjust to house style, add docs, or split the wiring differently — whatever makes this easiest to land.🤖 Drafted with Claude Code