Skip to content

feat(e2b-execution): add remote code execution to support Python + Imports#1226

Merged
icecrasher321 merged 8 commits intostagingfrom
feat/e2b-execution
Sep 3, 2025
Merged

feat(e2b-execution): add remote code execution to support Python + Imports#1226
icecrasher321 merged 8 commits intostagingfrom
feat/e2b-execution

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Sep 2, 2025

Summary

Use E2B for remote code execution. By default unless env vars are set to true to enable them, it uses our VM [Javascript only].

Error parsing correctly parses E2B returned error lines to user code editor lines.

Type of Change

  • New feature

Testing

Screen.Recording.2025-09-02.at.4.44.37.PM.mov

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Sep 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Sep 3, 2025 1:09am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 3, 2025 1:09am

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR introduces remote code execution capabilities using E2B sandboxes to support Python execution alongside the existing JavaScript-only VM. The implementation adds comprehensive support for dual execution modes - a fast local JavaScript VM and a slower but more capable remote E2B sandbox that supports both Python and JavaScript with imports.

The changes extend the Function block with new UI controls including a remote execution toggle switch and language dropdown (JavaScript/Python). The E2B integration is feature-flagged through environment variables (E2B_ENABLED, E2B_API_KEY, NEXT_PUBLIC_E2B_ENABLED) and disabled by default to ensure backward compatibility.

Key architectural components include:

  • Frontend Changes: New E2BSwitch component with conditional rendering, enhanced Code component with Python syntax highlighting, and sub-block filtering based on environment flags
  • Backend Integration: New E2B execution handler (lib/execution/e2b.ts) with proper sandbox lifecycle management, timeout handling, and result parsing
  • Type System Updates: Enhanced interfaces to support multi-language execution with CodeLanguage union type and improved type safety using unknown instead of any
  • Tool Enhancement: Updated function execution tool with language and fastMode parameters for execution mode control

The implementation follows established patterns in the codebase and maintains full backward compatibility - existing workflows continue using the JavaScript VM by default unless E2B is explicitly enabled. The execution routing logic intelligently chooses between local VM (fast mode) and remote E2B based on language selection and configuration flags.

Confidence score: 3/5

  • This PR introduces significant new functionality with external service dependencies that could cause runtime issues if E2B service is unavailable or misconfigured
  • Score reflects the complexity of the multi-execution-environment architecture and potential for inconsistent behavior between client/server environment flag states
  • Pay close attention to error handling in E2B integration, double JSON serialization logic in route.ts, and environment variable configuration consistency across client and server

12 files reviewed, 6 comments

Edit Code Review Bot Settings | Greptile

@vercel vercel bot temporarily deployed to Preview – docs September 3, 2025 01:03 Inactive
@icecrasher321 icecrasher321 merged commit 1a5d5dd into staging Sep 3, 2025
5 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/e2b-execution branch September 5, 2025 05:50
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…ports (simstudioai#1226)

* feat(e2b-execution): add remote code execution via e2b

* ux improvements

* fix streaming

* progress

* fix tooltip text

* make supported languages an enum

* fix error handling

* fix tests
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.

1 participant