improvement(code): add wand config and system prompt for python code generation, strip \n from stdout in JS/Python#1862
Merged
waleedlatif1 merged 1 commit intostagingfrom Nov 9, 2025
Merged
Conversation
…generation, strip \n from stdout in JS/Python
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
Enhances Python code generation and improves stdout formatting across JavaScript and Python execution paths.
Key Changes:
- Added
PYTHON_AI_PROMPTsystem prompt incode.tsxwith detailed instructions for AI-generated Python code, including parameter referencing (<paramName>) and environment variable syntax ({{ENV_VAR}}) - Implemented dynamic wand config that applies Python-specific prompt and placeholder when Python language is selected
- Introduced
cleanStdout()function inroute.tsthat strips one trailing newline from all execution outputs (VM and E2B paths) - Enhanced E2B execution in
e2b.tsto remove trailing empty lines after filtering result markers - Removed unused
remoteExecutionstate management from code editor component
Impact:
The changes improve UX by making stdout display match REPL/notebook behavior (no extra trailing newlines) and enable better AI-assisted Python code generation with language-specific prompts.
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The changes are well-contained, focused improvements with clear intent. The stdout cleaning logic is simple and defensive (only removes one trailing newline if present). The Python AI prompt addition is purely additive and doesn't affect existing JavaScript functionality. The removal of unused
remoteExecutioncode is clean refactoring. All changes follow existing patterns in the codebase. - No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/api/function/execute/route.ts | 5/5 | Added cleanStdout() helper to strip trailing newlines from execution output, applied consistently across all execution paths (VM and E2B) |
| apps/sim/lib/execution/e2b.ts | 5/5 | Enhanced E2B execution to remove trailing empty lines from stdout after filtering result markers, improving output consistency |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/code/code.tsx | 5/5 | Removed remoteExecution state management (now unused), added Python-specific AI prompt and dynamic wand config based on language selection |
Sequence Diagram
sequenceDiagram
participant User
participant CodeEditor as Code Editor Component
participant WandHook as useWand Hook
participant ExecuteAPI as /api/function/execute
participant E2B as E2B Sandbox
Note over CodeEditor: User selects Python language
CodeEditor->>CodeEditor: dynamicWandConfig computed<br/>PYTHON_AI_PROMPT applied
CodeEditor->>WandHook: Initialize with dynamicWandConfig
User->>CodeEditor: Write/generate Python code
CodeEditor->>ExecuteAPI: POST code with language='python'
ExecuteAPI->>ExecuteAPI: resolveCodeVariables()<br/>Wrap code with prologue
ExecuteAPI->>E2B: executeInE2B(code, 'python', timeout)
E2B->>E2B: runCode() in sandbox
E2B->>E2B: Filter __SIM_RESULT__ marker
E2B->>E2B: Remove trailing empty line
E2B-->>ExecuteAPI: {result, stdout, sandboxId}
ExecuteAPI->>ExecuteAPI: cleanStdout(stdout)<br/>Strip trailing \n
ExecuteAPI-->>CodeEditor: {success, output: {result, stdout}}
CodeEditor-->>User: Display cleaned output
3 files reviewed, no comments
waleedlatif1
added a commit
that referenced
this pull request
Nov 9, 2025
…generation, strip \n from stdout in JS/Python (#1862)
waleedlatif1
added a commit
that referenced
this pull request
Nov 9, 2025
…generation, strip \n from stdout in JS/Python (#1862)
waleedlatif1
added a commit
that referenced
this pull request
Nov 12, 2025
…generation, strip \n from stdout in JS/Python (#1862)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
\nfrom stdout in JS/Python (same way jupyter notebook and repl's do it)Type of Change
Testing
Tested manually
Checklist