feat(e2b-execution): add remote code execution to support Python + Imports#1226
feat(e2b-execution): add remote code execution to support Python + Imports#1226icecrasher321 merged 8 commits intostagingfrom
Conversation
There was a problem hiding this comment.
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
CodeLanguageunion type and improved type safety usingunknowninstead ofany - Tool Enhancement: Updated function execution tool with
languageandfastModeparameters 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
.../sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx
Show resolved
Hide resolved
...rkspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/code.tsx
Show resolved
Hide resolved
…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
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
Testing
Screen.Recording.2025-09-02.at.4.44.37.PM.mov
Checklist