Skip to content

Add E2B terminal backend (create + attach modes) - #90226

Closed
VCoder25 wants to merge 1 commit into
NousResearch:mainfrom
VCoder25:feat/e2b-terminal-backend
Closed

Add E2B terminal backend (create + attach modes)#90226
VCoder25 wants to merge 1 commit into
NousResearch:mainfrom
VCoder25:feat/e2b-terminal-backend

Conversation

@VCoder25

Copy link
Copy Markdown

Adds an e2b terminal backend so Hermes can use E2B sandboxes as its computer, alongside the existing modal/daytona/vercel cloud backends.

What's included

  • tools/environments/e2b.pyE2BEnvironment implementing BaseEnvironment, modeled closely on the Daytona backend (_ThreadedProcessHandle over blocking SDK calls, heredoc stdin mode).
  • 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; a guarded check_terminal_requirements branch (missing SDK → clear log + False, not a crash).

Design decisions (learned the hard way, live-tested)

  • Sliding TTL: E2B's timeout is an absolute expiry, unlike an idle reaper — so it's renewed via set_timeout() before every command; long agent turns can't lose their computer.
  • Non-destructive cancel: BaseEnvironment fires cancel_fn on 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.
  • Attach mode: TERMINAL_E2B_SANDBOX_ID connects to an externally owned sandbox via Sandbox.connect() and never kills it on cleanup — for outer orchestrators that own sandbox lifecycle (create mode still kills its own).
  • Fail-closed template: create mode refuses an empty template rather than silently falling back to E2B's base image.

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

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).
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have tool/terminal Terminal execution and process management duplicate This issue or pull request already exists labels Aug 19, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

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.

@VCoder25

Copy link
Copy Markdown
Author

Closing — duplicate of #18348.

@VCoder25 VCoder25 closed this Aug 19, 2026
@VCoder25
VCoder25 deleted the feat/e2b-terminal-backend branch August 19, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have tool/terminal Terminal execution and process management type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants