fix(rce): always use VM over RCE for custom tools#1233
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR addresses a critical consistency issue in code execution for custom tools. The change modifies the execution path selection logic in /apps/sim/app/api/function/execute/route.ts to prevent custom tools from using E2B (external sandbox execution) and forces them to always use the local VM instead.
The core modification adds !isCustomTool to the condition that determines whether to use E2B execution:
const useE2B =
e2bEnabled &&
!useLocalVM &&
!isCustomTool && // <- This line was added
(lang === CodeLanguage.JavaScript || lang === CodeLanguage.Python)This change ensures that custom tools maintain consistent behavior with their existing parameter handling logic. The codebase already has special handling for custom tools in the local VM execution path (lines 759-764) where execution parameters are made directly accessible as variables (e.g., const location = params.location). Without this fix, when E2B was enabled, custom tools could bypass this specialized parameter resolution and use the E2B sandbox instead, potentially breaking their expected variable access patterns.
The fix integrates seamlessly with the existing architecture - the local VM execution path already contains the necessary custom tool handling logic, so by simply preventing the E2B execution path for custom tools, the PR ensures they always receive the consistent parameter handling they require for proper functionality.
Confidence score: 5/5
- This PR is extremely safe to merge with virtually no risk of breaking existing functionality
- Score reflects a minimal, well-targeted change that fixes a specific inconsistency without affecting other execution paths
- No files require special attention as the change is isolated and surgical
1 file reviewed, no comments
Summary
always use VM over RCE for custom tools, for consistency with variable/envvar resolution
Type of Change
Testing
Tested manually.
Checklist