mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[GH-ISSUE #20941] feat: Code Interpreter: strip markdown code fences before executing in Pyodide #58002
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mgcrea on GitHub (Jan 26, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/20941
Check Existing Issues
Verify Feature Scope
Problem Description
Bug description
When using the Code Interpreter with models that wrap code in markdown fences (
```python ... ```), the Pyodide runtime receives the backticks as part of the source code, causing:This is a very common LLM behavior, most models are trained to emit markdown-fenced code blocks. The current approach relies entirely on the system prompt to suppress this, which is fragile and model-dependent.
Desired Solution you'd like
Proposed fix
Before passing code to Pyodide's
eval_code_async, strip leading/trailing markdown code fences:This is a defensive, non-breaking change — if the code doesn't contain fences, it passes through unchanged.
Alternatives Considered
Why this matters
Additional Context
Environment
@tjbck commented on GitHub (Jan 26, 2026):
Should be addressed in dev.