[GH-ISSUE #22309] issue: Image generation fails in temporary chat mode #35222

Closed
opened 2026-04-25 09:27:22 -05:00 by GiteaMirror · 11 comments
Owner

Originally created by @wsomm on GitHub (Mar 6, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/22309

Check Existing Issues

  • I have searched for any existing and/or related issues.
  • I have searched for any existing and/or related discussions.
  • I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!).
  • I am using the latest version of Open WebUI.

Installation Method

Pip Install

Open WebUI Version

0.8.8

Ollama Version (if applicable)

No response

Operating System

Mac os Tahoe

Browser (if applicable)

No response

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

Generate me a picture of a sunset.
Expected: the generated picture.

Actual Behavior

The picture is generated but not displayed.
Happening with Nanao Banana and tool call with gpt-oss with configured image generation.

Steps to Reproduce

Just call "paint me a picture of a sunset" on a Google Nano Banana model.

Logs & Screenshots

No log entries found.

Additional Information

Note: Sometimes it works. Arbitrarily.

Originally created by @wsomm on GitHub (Mar 6, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/22309 ### Check Existing Issues - [x] I have searched for any existing and/or related issues. - [x] I have searched for any existing and/or related discussions. - [x] I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!). - [x] I am using the latest version of Open WebUI. ### Installation Method Pip Install ### Open WebUI Version 0.8.8 ### Ollama Version (if applicable) _No response_ ### Operating System Mac os Tahoe ### Browser (if applicable) _No response_ ### 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 Generate me a picture of a sunset. Expected: the generated picture. ### Actual Behavior The picture is generated but not displayed. Happening with Nanao Banana and tool call with gpt-oss with configured image generation. ### Steps to Reproduce Just call "paint me a picture of a sunset" on a Google Nano Banana model. ### Logs & Screenshots No log entries found. ### Additional Information Note: _Sometimes_ it works. Arbitrarily.
GiteaMirror added the bug label 2026-04-25 09:27:22 -05:00
Author
Owner

@Classic298 commented on GitHub (Mar 6, 2026):

just tested, works. cannot reproduce.

Image

Gemini 3 Pro Image Preview was used, native tool calling.

<!-- gh-comment-id:4011427324 --> @Classic298 commented on GitHub (Mar 6, 2026): just tested, works. cannot reproduce. <img width="1116" height="749" alt="Image" src="https://github.com/user-attachments/assets/4cffe881-deb1-4e46-aea7-505c98f55457" /> Gemini 3 Pro Image Preview was used, native tool calling.
Author
Owner

@wsomm commented on GitHub (Mar 6, 2026):

Ok. But doesn't work here! Additional information I found:

when it works the log contains:

'chat_id': 'f738d756-d6f5-4602-bdb2-8735d8284f73'
'session_id': 'clNcq2vFb7PXzWAYAAAH'

GET /api/v1/chats/?page=1 HTTP/1.1" 200

'output': []
'usage': {
  'completion_tokens': 1356,
  'prompt_tokens': 7,
  'total_tokens': 1363,
  'completion_tokens_details': {
    'reasoning_tokens': 139,
    'text_tokens': 97,
    'image_tokens': 1120
  }
}

When it fails in temporary chat the log is

'chat_id': 'local:clNcq2vFb7PXzWAYAAAH'
'session_id': 'clNcq2vFb7PXzWAYAAAH'

(*no* GET /api/v1/chats/)
(*no* 'output' block)
(*no* 'usage' block)

I am willing to do anything to solve this, at the moment it looks like a failure in OWUI 0.8.8
And as I already wrote: sometimes it works even here.

At the moment I have no idea where to search else.
The pic is generated, but not displayed. And only in temporary chat.

<!-- gh-comment-id:4011644554 --> @wsomm commented on GitHub (Mar 6, 2026): Ok. But doesn't work here! Additional information I found: when it works the log contains: ``` 'chat_id': 'f738d756-d6f5-4602-bdb2-8735d8284f73' 'session_id': 'clNcq2vFb7PXzWAYAAAH' GET /api/v1/chats/?page=1 HTTP/1.1" 200 'output': [] 'usage': { 'completion_tokens': 1356, 'prompt_tokens': 7, 'total_tokens': 1363, 'completion_tokens_details': { 'reasoning_tokens': 139, 'text_tokens': 97, 'image_tokens': 1120 } } ``` When it fails in temporary chat the log is ``` 'chat_id': 'local:clNcq2vFb7PXzWAYAAAH' 'session_id': 'clNcq2vFb7PXzWAYAAAH' (*no* GET /api/v1/chats/) (*no* 'output' block) (*no* 'usage' block) ``` I am willing to do anything to solve this, at the moment it looks like a failure in OWUI 0.8.8 And as I already wrote: _sometimes_ it works even here. At the moment I have no idea where to search else. The pic is generated, but not displayed. And only in temporary chat.
Author
Owner

@Classic298 commented on GitHub (Mar 6, 2026):

how did you configure your image generation settings?
what reverse proxy settings?
any console logs or browser logs of the image perhaps getting blocked or failing to load?

<!-- gh-comment-id:4011675649 --> @Classic298 commented on GitHub (Mar 6, 2026): how did you configure your image generation settings? what reverse proxy settings? any console logs or browser logs of the image perhaps getting blocked or failing to load?
Author
Owner

@wsomm commented on GitHub (Mar 6, 2026):

This is straight to Google Nano Banana, but through liteLLM Poxy.
Reverse Proxy is via apache2.

One additional thing: In temporary mode no image is stored in the upload folder, in normal mode it is.
But this might be intended behaviour to be private.

I'll check, if I find something on the reverse proxy side, that might be a potential point of failure.

<!-- gh-comment-id:4011696458 --> @wsomm commented on GitHub (Mar 6, 2026): This is straight to Google Nano Banana, but through liteLLM Poxy. Reverse Proxy is via apache2. One additional thing: In temporary mode no image is stored in the upload folder, in normal mode it is. But this might be intended behaviour to be private. I'll check, if I find something on the reverse proxy side, that might be a potential point of failure.
Author
Owner

@Classic298 commented on GitHub (Mar 6, 2026):

yes its intended to not be stored in the upload folder
anything in the browser network logs and console logs?

<!-- gh-comment-id:4011719145 --> @Classic298 commented on GitHub (Mar 6, 2026): yes its intended to not be stored in the upload folder anything in the browser network logs and console logs?
Author
Owner

@wsomm commented on GitHub (Mar 6, 2026):

I have 503 errors in the websocket communication, this would explain the behaviour. I'll investigate further. Thank you.

<!-- gh-comment-id:4011802891 --> @wsomm commented on GitHub (Mar 6, 2026): I have 503 errors in the websocket communication, this would explain the behaviour. I'll investigate further. Thank you.
Author
Owner

@wsomm commented on GitHub (Mar 6, 2026):

ok. the websocket had nothing to do with the problem.
I had Claude code investigate the problem and it came up with a fix that worked. Here is the summary:

Bug: Images not displayed in Temporary Chat when using builtin generate_image tool (native function calling)

Description

When using a model configured with builtin tools (native function calling) for image generation, generated images are not displayed in Temporary Chat mode. The image is successfully generated and uploaded to the server, but the frontend never receives the file event, so nothing is shown.

In normal (persistent) chat mode, the same model displays images correctly.

Root Cause

The bug is in 3 locations where Chats.add_message_files_by_id_and_message_id() is called. This function returns None when the chat doesn't exist in the database — which is always the case for temporary chats (chat IDs starting with local:).

Primary location — open_webui/tools/builtin.py, generate_image() function (~line 249-260):

# Line 249: image_files is correctly created
image_files = [{"type": "image", "url": img["url"]} for img in images]

# Line 252-257: image_files is OVERWRITTEN with the DB return value
if __chat_id__ and __message_id__ and images:
    image_files = Chats.add_message_files_by_id_and_message_id(
        __chat_id__,       # "local:abc123..." for temporary chats
        __message_id__,
        image_files,
    )
    # For temporary chats: image_files is now None!
    # (because add_message_files_by_id_and_message_id returns None
    #  when get_chat_by_id() finds no matching chat in the DB)

# Line 260: None is falsy → event is NEVER emitted to the frontend
if __event_emitter__ and image_files:   # ← False because image_files is None
    await __event_emitter__(...)         # ← never executed

The same pattern exists in:

  • open_webui/tools/builtin.py, edit_image() function (~line 317-325) — identical bug
  • open_webui/utils/middleware.py, SSE streaming handler (~line 3770-3784) — emits {"files": null} instead of the image list

Why this bug is hard to reproduce

This bug only affects the builtin tool (native function calling) code path, not the feature-based image generation path. Which path is taken depends on the model configuration:

Model Config Code Path Temporary Chat
capabilities.image_generation: true + no native FC chat_image_generation_handler() in middleware.py (line 1767) Works — emits files directly without DB lookup
builtinTools.image_generation: true (native FC) generate_image() in builtin.py (line 253) Broken — DB lookup returns None, event never sent

Most users and testers likely use models where image_generation is set as a capability (the older/simpler approach), which uses chat_image_generation_handler(). This handler constructs the files event directly from the image_generations() return value and emits it without going through the DB — so it works fine in temporary chats.

The bug only manifests when a model uses the builtin tools approach (native function calling), where generate_image in builtin.py is invoked as a tool call by the LLM. This is the newer approach used by models configured with builtinTools: { image_generation: true }.

Fix

The fix is minimal — don't overwrite image_files when the DB function returns None:

builtin.py (generate_image and edit_image):

if __chat_id__ and __message_id__ and images:
    db_files = Chats.add_message_files_by_id_and_message_id(
        __chat_id__,
        __message_id__,
        image_files,
    )
    if db_files is not None:
        image_files = db_files

middleware.py (SSE streaming handler):

if image_urls:
    image_file_list = [
        {"type": "image", "url": url}
        for url in image_urls
    ]
    message_files = Chats.add_message_files_by_id_and_message_id(
        metadata["chat_id"],
        metadata["message_id"],
        image_file_list,
    )
    if message_files is None:
        message_files = image_file_list

    await event_emitter(
        {"type": "files", "data": {"files": message_files}}
    )

Steps to Reproduce

  1. Configure a model with builtinTools: { image_generation: true } and capabilities: { image_generation: false } (i.e., image generation via native function calling, not via the feature flag)
  2. Enable Temporary Chat mode
  3. Ask the model to generate an image (e.g., "Generate an image of a sunset")
  4. The image is generated server-side (visible in logs/file storage) but never displayed in the chat
  5. Disable Temporary Chat → same request works perfectly

Environment

  • Open WebUI v0.8.8
  • Tested with Google Gemini model configured for builtin tool-based image generation

WebSocket Evidence

In temporary chat, the socket event shows files: null:

42["events",{"chat_id":"local:X06_3wdNJq-yRZwxAABB","message_id":"...","data":{"type":"files","data":{"files":null}}}]

After the fix, it correctly sends the image file list.

<!-- gh-comment-id:4012277455 --> @wsomm commented on GitHub (Mar 6, 2026): ok. the websocket had nothing to do with the problem. I had Claude code investigate the problem and it came up with a fix that worked. Here is the summary: ## Bug: Images not displayed in Temporary Chat when using builtin `generate_image` tool (native function calling) ### Description When using a model configured with **builtin tools** (native function calling) for image generation, generated images are **not displayed** in **Temporary Chat** mode. The image is successfully generated and uploaded to the server, but the frontend never receives the file event, so nothing is shown. In **normal (persistent) chat** mode, the same model displays images correctly. ### Root Cause The bug is in **3 locations** where `Chats.add_message_files_by_id_and_message_id()` is called. This function returns `None` when the chat doesn't exist in the database — which is always the case for temporary chats (chat IDs starting with `local:`). **Primary location — `open_webui/tools/builtin.py`, `generate_image()` function (~line 249-260):** ```python # Line 249: image_files is correctly created image_files = [{"type": "image", "url": img["url"]} for img in images] # Line 252-257: image_files is OVERWRITTEN with the DB return value if __chat_id__ and __message_id__ and images: image_files = Chats.add_message_files_by_id_and_message_id( __chat_id__, # "local:abc123..." for temporary chats __message_id__, image_files, ) # For temporary chats: image_files is now None! # (because add_message_files_by_id_and_message_id returns None # when get_chat_by_id() finds no matching chat in the DB) # Line 260: None is falsy → event is NEVER emitted to the frontend if __event_emitter__ and image_files: # ← False because image_files is None await __event_emitter__(...) # ← never executed ``` The same pattern exists in: - `open_webui/tools/builtin.py`, `edit_image()` function (~line 317-325) — identical bug - `open_webui/utils/middleware.py`, SSE streaming handler (~line 3770-3784) — emits `{"files": null}` instead of the image list ### Why this bug is hard to reproduce This bug **only affects the builtin tool (native function calling) code path**, not the feature-based image generation path. Which path is taken depends on the model configuration: | Model Config | Code Path | Temporary Chat | |---|---|---| | `capabilities.image_generation: true` + no native FC | `chat_image_generation_handler()` in middleware.py (line 1767) | **Works** — emits files directly without DB lookup | | `builtinTools.image_generation: true` (native FC) | `generate_image()` in builtin.py (line 253) | **Broken** — DB lookup returns None, event never sent | Most users and testers likely use models where `image_generation` is set as a **capability** (the older/simpler approach), which uses `chat_image_generation_handler()`. This handler constructs the files event directly from the `image_generations()` return value and emits it without going through the DB — so it works fine in temporary chats. The bug only manifests when a model uses the **builtin tools** approach (native function calling), where `generate_image` in `builtin.py` is invoked as a tool call by the LLM. This is the newer approach used by models configured with `builtinTools: { image_generation: true }`. ### Fix The fix is minimal — don't overwrite `image_files` when the DB function returns `None`: **builtin.py** (`generate_image` and `edit_image`): ```python if __chat_id__ and __message_id__ and images: db_files = Chats.add_message_files_by_id_and_message_id( __chat_id__, __message_id__, image_files, ) if db_files is not None: image_files = db_files ``` **middleware.py** (SSE streaming handler): ```python if image_urls: image_file_list = [ {"type": "image", "url": url} for url in image_urls ] message_files = Chats.add_message_files_by_id_and_message_id( metadata["chat_id"], metadata["message_id"], image_file_list, ) if message_files is None: message_files = image_file_list await event_emitter( {"type": "files", "data": {"files": message_files}} ) ``` ### Steps to Reproduce 1. Configure a model with `builtinTools: { image_generation: true }` and `capabilities: { image_generation: false }` (i.e., image generation via native function calling, not via the feature flag) 2. Enable **Temporary Chat** mode 3. Ask the model to generate an image (e.g., "Generate an image of a sunset") 4. The image is generated server-side (visible in logs/file storage) but **never displayed** in the chat 5. Disable Temporary Chat → same request works perfectly ### Environment - Open WebUI v0.8.8 - Tested with Google Gemini model configured for builtin tool-based image generation ### WebSocket Evidence In temporary chat, the socket event shows `files: null`: ```json 42["events",{"chat_id":"local:X06_3wdNJq-yRZwxAABB","message_id":"...","data":{"type":"files","data":{"files":null}}}] ``` After the fix, it correctly sends the image file list.
Author
Owner

@Classic298 commented on GitHub (Mar 6, 2026):

going to investigate

<!-- gh-comment-id:4012565897 --> @Classic298 commented on GitHub (Mar 6, 2026): going to investigate
Author
Owner

@Classic298 commented on GitHub (Mar 6, 2026):

https://github.com/open-webui/open-webui/pull/22330

<!-- gh-comment-id:4013267746 --> @Classic298 commented on GitHub (Mar 6, 2026): https://github.com/open-webui/open-webui/pull/22330
Author
Owner

@tjbck commented on GitHub (Mar 7, 2026):

Addressed in dev.

<!-- gh-comment-id:4017614633 --> @tjbck commented on GitHub (Mar 7, 2026): Addressed in dev.
Author
Owner

@Classic298 commented on GitHub (Mar 7, 2026):

d4faa5a5ea

<!-- gh-comment-id:4017614915 --> @Classic298 commented on GitHub (Mar 7, 2026): https://github.com/open-webui/open-webui/commit/d4faa5a5eafe4159dc46aa1d19a7477401e5e7e9
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#35222