Skip to content

Conversation

embersax
Copy link
Contributor

@embersax embersax commented Sep 5, 2025

  • Upgrade E2B SDK from v1.7.1 to e2b-code-interpreter v2.0.0
  • Implement all required abstract methods (run, run_ipython, edit, browse)
  • Add sandbox lifecycle management with caching for reconnection
  • Support custom E2B domains via E2B_DOMAIN environment variable
  • Fix API compatibility issues with E2B v2
  • Add comprehensive error handling and logging

This enables full E2B runtime support for running OpenHands agents in
cloud-based sandboxes, including support for self-hosted E2B instances.

  • This change is worth documenting at https://docs.all-hands.dev/
  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

End-user friendly description of the problem this fixes or functionality this introduces:

This update enables OpenHands to run agents in E2B cloud sandboxes, providing a secure and scalable alternative to Docker. Users can now:

  • Run OpenHands without Docker by using E2B's cloud-based sandboxes
  • Use self-hosted E2B instances for better control and performance
  • Scale evaluations across multiple sandboxes in the cloud
  • Run SWE-bench and other benchmarks at scale using E2B infrastructure

Simply set your E2B API key and use RUNTIME=e2b to get started!


Summarize what the PR does, explaining any non-trivial design decisions:

This PR completely overhauls the E2B runtime integration:

  1. SDK Upgrade: Migrated from deprecated e2b v1.7.1 to e2b-code-interpreter v2.0.0, which required significant API changes
  2. Full Implementation: The previous E2B runtime only supported file operations. This PR implements all required methods:
    • Command execution via native E2B sandbox
    • IPython/Jupyter support using E2B's built-in code interpreter
    • File editing capabilities
    • URL browsing via curl/wget
  3. Sandbox Lifecycle Management: Added intelligent caching mechanism that allows reconnecting to existing sandboxes, reducing startup time and costs
  4. Self-hosted Support: Added E2B_DOMAIN environment variable support for users running E2B on their own infrastructure
  5. Design Decision: Instead of running an HTTP action server inside E2B (which would be inefficient), we override the execution methods to directly use E2B's native APIs

The implementation maintains full compatibility with OpenHands' architecture while leveraging E2B's strengths as a cloud-native sandbox solution.


Link of any specific issues this addresses:

N/A - This is a feature enhancement to complete the E2B runtime implementation.

  - Upgrade E2B SDK from v1.7.1 to e2b-code-interpreter v2.0.0
  - Implement all required abstract methods (run, run_ipython, edit, browse)
  - Add sandbox lifecycle management with caching for reconnection
  - Support custom E2B domains via E2B_DOMAIN environment variable
  - Fix API compatibility issues with E2B v2
  - Add comprehensive error handling and logging

  This enables full E2B runtime support for running OpenHands agents in
  cloud-based sandboxes, including support for self-hosted E2B instances.
Copy link
Collaborator

@enyst enyst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this!

I just had a little comment about optional deps.

- Move e2b-code-interpreter to optional dependencies in pyproject.toml
- Update extras to reference e2b-code-interpreter instead of 'e2b'
- Update poetry.lock to reflect optional status

This ensures E2B dependencies are only installed when users explicitly
request them via 'pip install openhands[third_party_runtimes]'
@embersax embersax force-pushed the feat/e2b-runtime-v2-integration branch from 68d0841 to 4979ed8 Compare September 7, 2025 22:53
@enyst
Copy link
Collaborator

enyst commented Sep 8, 2025

@OpenHands You know how to build and run this project. Run make build and make run, to make sure it continues to work normally when built without the optional dependency updated in this PR.

You don’t need to test it, you don’t have a key for it, so we took care of that part.

Copy link

openhands-ai bot commented Sep 8, 2025

I'm on it! enyst can track my progress at all-hands.dev

🟡 Solvability: MEDIUM

MEDIUM: The request is to run “make build” and “make run” to confirm the project still works when built without an optional dependency; the steps are clear but there’s little context about the project and environment. Missing guidance on how to exclude that dependency and what a successful outcome looks like may slow resolution.

You can make the issue easier to resolve by addressing these concerns in the conversation:

  • Provide the repo/PR link and branch, the working directory, and prerequisites (OS, architecture, required toolchain and runtime versions) to run the commands.
  • Specify exactly how to build “without the optional dependency” (flags, environment variables, or Makefile targets) and describe the expected successful output for each command.
  • List any setup steps (dependency installation, submodules, container vs. local build, cache cleanup) needed before running the commands.

Positive feedback:

  • The task is narrowly scoped with clear, concrete commands to execute.
  • No credentialed tests are required, which reduces setup complexity and risk.
  • The goal is a simple sanity check rather than deep debugging, keeping the effort focused.

Copy link

openhands-ai bot commented Sep 8, 2025

Task Completion Summary

I successfully completed the requested task to run make build and make run to verify that the OpenHands project continues to work normally with the E2B runtime v2 integration changes.

What I Did:

  1. Set up the environment: Installed missing Node.js/npm dependencies required for the build process
  2. Executed make build: Successfully built the entire project including:
    • Python backend dependencies
    • React frontend with Vite
    • VSCode extension packaging
    • Pre-commit hooks installation
  3. Executed make run: Successfully started and ran the application with all services operational:
    • Backend server (port 3000)
    • Action execution server (port 37491)
    • File viewer server
    • Browser environment
    • MCP Proxy Manager

Key Results:

Build completed successfully - No errors or failures related to E2B integration
Application runs normally - All core services initialized and operated without issues
No E2B-related errors - The optional dependency updates do not break normal functionality
Stable operation - Application ran continuously until manually interrupted

Answer to Your Request:

The project continues to work normally when built without the optional E2B dependency. The E2B runtime v2 integration changes do not interfere with standard operation, and the application builds and runs successfully using the default local runtime configuration.

No code changes were made - this was purely a verification task to ensure the build and run processes work correctly with the E2B integration updates.

View full conversation

Copy link
Collaborator

@enyst enyst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Just a heads-up, we’re just about to make a large migration to agent-sdk. I don’t know if we will make a release before that is completed, but it’s intended to be relatively fast. 😅

@enyst enyst merged commit 9960d11 into All-Hands-AI:main Sep 8, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants