[GH-ISSUE #17181] issue: Code interpreter output formatting seems off #56863

Closed
opened 2026-05-05 20:10:53 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @rbx on GitHub (Sep 3, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/17181

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of Open WebUI.

Installation Method

Pip Install

Open WebUI Version

v0.6.26

Ollama Version (if applicable)

0.11.7

Operating System

Fedora 42

Browser (if applicable)

Firefox

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc).
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation. My steps:
  • Start with the initial platform/version/OS and dependencies used,
  • Specify exact install/launch/configure commands,
  • List URLs visited, user input (incl. example values/emails/passwords if needed),
  • Describe all options and toggles enabled or changed,
  • Include any files or environmental changes,
  • Identify the expected and actual result at each stage,
  • Ensure any reasonably skilled user can follow and hit the same issue.

Expected Behavior

"Analyze" block should appear, showing only relevant code when unfolded, with a clean LLM reply afterwards. If relevant, it is using pydiode for execution.

Actual Behavior

Image

Steps to Reproduce

Launch any task where LLM would write and execute code and examine the result, such as in the screenshot above.

Logs & Screenshots

Screenshot above.

Additional Information

After tinkering a bit with Claude Code I could get it to work with:

-                        content_stripped, original_whitespace = (
-                            split_content_and_whitespace(content)
-                        )
-                        if is_opening_code_block(content_stripped):
-                            # Remove trailing backticks that would open a new block
-                            content = (
-                                content_stripped.rstrip("`").rstrip()
-                                + original_whitespace
-                            )
-                        else:
-                            # Keep content as is - either closing backticks or no backticks
-                            content = content_stripped + original_whitespace
+                        # Remove any trailing code block markers
+                        content_stripped = content.rstrip()
+
+                        # Remove trailing ```python or ``` markers that would conflict with our details block
+                        if content_stripped.endswith("```python"):
+                            content_stripped = content_stripped[:-9].rstrip()
+                        elif content_stripped.endswith("```"):
+                            content_stripped = content_stripped[:-3].rstrip()
+
+                        content = content_stripped

in https://github.com/open-webui/open-webui/blob/dev/backend/open_webui/utils/middleware.py#L1562
Then the output becomes:

Image

But not sure if this is a good solution.

Originally created by @rbx on GitHub (Sep 3, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/17181 ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Pip Install ### Open WebUI Version v0.6.26 ### Ollama Version (if applicable) 0.11.7 ### Operating System Fedora 42 ### Browser (if applicable) Firefox ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have clearly **listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup** (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc). - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. My steps: - Start with the initial platform/version/OS and dependencies used, - Specify exact install/launch/configure commands, - List URLs visited, user input (incl. example values/emails/passwords if needed), - Describe all options and toggles enabled or changed, - Include any files or environmental changes, - Identify the expected and actual result at each stage, - Ensure any reasonably skilled user can follow and hit the same issue. ### Expected Behavior "Analyze" block should appear, showing only relevant code when unfolded, with a clean LLM reply afterwards. If relevant, it is using pydiode for execution. ### Actual Behavior <img width="1015" height="433" alt="Image" src="https://github.com/user-attachments/assets/07036667-dd6d-499a-bb4b-c0f89bad4042" /> ### Steps to Reproduce Launch any task where LLM would write and execute code and examine the result, such as in the screenshot above. ### Logs & Screenshots Screenshot above. ### Additional Information After tinkering a bit with Claude Code I could get it to work with: ```diff - content_stripped, original_whitespace = ( - split_content_and_whitespace(content) - ) - if is_opening_code_block(content_stripped): - # Remove trailing backticks that would open a new block - content = ( - content_stripped.rstrip("`").rstrip() - + original_whitespace - ) - else: - # Keep content as is - either closing backticks or no backticks - content = content_stripped + original_whitespace + # Remove any trailing code block markers + content_stripped = content.rstrip() + + # Remove trailing ```python or ``` markers that would conflict with our details block + if content_stripped.endswith("```python"): + content_stripped = content_stripped[:-9].rstrip() + elif content_stripped.endswith("```"): + content_stripped = content_stripped[:-3].rstrip() + + content = content_stripped ``` in https://github.com/open-webui/open-webui/blob/dev/backend/open_webui/utils/middleware.py#L1562 Then the output becomes: <img width="1013" height="427" alt="Image" src="https://github.com/user-attachments/assets/940e7f5c-6e95-44df-8a24-b59e51e9314e" /> But not sure if this is a good solution.
GiteaMirror added the bug label 2026-05-05 20:10:54 -05:00
Author
Owner

@tjbck commented on GitHub (Sep 6, 2025):

This is caused by the model not following the prompt instructions, if you use a higher end model like gpt-4o, you won't be encountering this issue.

<!-- gh-comment-id:3263177365 --> @tjbck commented on GitHub (Sep 6, 2025): This is caused by the model not following the prompt instructions, if you use a higher end model like gpt-4o, you won't be encountering this issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#56863