[GH-ISSUE #21457] issue: File context does not uses when no user message entered, but system prompt exists. #35016

Closed
opened 2026-04-25 09:13:15 -05:00 by GiteaMirror · 29 comments
Owner

Originally created by @Creearc on GitHub (Feb 16, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/21457

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

Docker

Open WebUI Version

v0.8.1

Ollama Version (if applicable)

No response

Operating System

Ubuntu 22.04

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

The model should use the attached document as context when a system promp exists and no user message provided.

Actual Behavior

The model fails to use the attached document as context when only a system prompt is provided without an accompanying user message.

Steps to Reproduce

To reproduce that you should create model with system prompt, load file with some information (in my case it was trinscribed audio) and press Enter to send message to model (with no text in message). Model will anwer that it has no files context.

Logs & Screenshots

Model config:
Image

Model answer:
Image

File content:
Image

Additional Information

The problem is with middleware.py it has a couple of checks wich does not add file content to context if no text in last user message provided.

Originally created by @Creearc on GitHub (Feb 16, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/21457 ### 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 Docker ### Open WebUI Version v0.8.1 ### Ollama Version (if applicable) _No response_ ### Operating System Ubuntu 22.04 ### 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 The model should use the attached document as context when a system promp exists and no user message provided. ### Actual Behavior The model fails to use the attached document as context when only a system prompt is provided without an accompanying user message. ### Steps to Reproduce To reproduce that you should create model with system prompt, load file with some information (in my case it was trinscribed audio) and press Enter to send message to model (with no text in message). Model will anwer that it has no files context. ### Logs & Screenshots Model config: <img width="707" height="381" alt="Image" src="https://github.com/user-attachments/assets/72ecfd85-4e74-4783-afe5-c54cb21df17c" /> Model answer: <img width="1033" height="320" alt="Image" src="https://github.com/user-attachments/assets/51b68400-348c-4be1-a581-276e0f10ee2c" /> File content: <img width="577" height="112" alt="Image" src="https://github.com/user-attachments/assets/fce4ece0-3eff-44a1-98ac-026bca33c181" /> ### Additional Information The problem is with middleware.py it has a couple of checks wich does not add file content to context if no text in last user message provided.
GiteaMirror added the bug label 2026-04-25 09:13:15 -05:00
Author
Owner

@Steve-Li-1998 commented on GitHub (Feb 16, 2026):

I’m using an external API, but it seems that regardless of whether I provide a prompt, the attachment isn’t being correctly sent to the model based on the token consumption.

Image Image Image
<!-- gh-comment-id:3907628305 --> @Steve-Li-1998 commented on GitHub (Feb 16, 2026): I’m using an external API, but it seems that regardless of whether I provide a prompt, the attachment isn’t being correctly sent to the model based on the token consumption. <img width="755" height="343" alt="Image" src="https://github.com/user-attachments/assets/790db9c1-b426-4e03-92ee-32f19d6d8d5a" /> <img width="768" height="478" alt="Image" src="https://github.com/user-attachments/assets/cfe5b5bc-0a72-4493-9c29-cfeee74ce671" /> <img width="772" height="491" alt="Image" src="https://github.com/user-attachments/assets/df7a5b9e-7448-4648-a1d0-2ede8037b2d6" />
Author
Owner

@Steve-Li-1998 commented on GitHub (Feb 16, 2026):

Image Image
<!-- gh-comment-id:3907638906 --> @Steve-Li-1998 commented on GitHub (Feb 16, 2026): <img width="746" height="479" alt="Image" src="https://github.com/user-attachments/assets/b883e9e4-3fa2-4203-bc23-c3070aec5c77" /> <img width="769" height="470" alt="Image" src="https://github.com/user-attachments/assets/4f82248b-240e-413c-a042-91e0fecee4ff" />
Author
Owner

@Steve-Li-1998 commented on GitHub (Feb 16, 2026):

And following is the performance of v0.8.1

Image Image
<!-- gh-comment-id:3907662157 --> @Steve-Li-1998 commented on GitHub (Feb 16, 2026): And following is the performance of v0.8.1 <img width="774" height="484" alt="Image" src="https://github.com/user-attachments/assets/6042c60c-71ab-4ca1-8598-03426072b4e9" /> <img width="791" height="448" alt="Image" src="https://github.com/user-attachments/assets/94e27773-e180-4c62-b31e-c3a05314276c" />
Author
Owner

@Classic298 commented on GitHub (Feb 16, 2026):

This is basically intended.

How should the RAG pipeline be able to generate RAG queries if you didnt provide any text? It can't.
Also many external models like Claude will simply error out if you send an empty message.
You should not send empty messages.

Leaving this open for @tjbck to see/triage.

<!-- gh-comment-id:3907722690 --> @Classic298 commented on GitHub (Feb 16, 2026): This is basically intended. How should the RAG pipeline be able to generate RAG queries if you didnt provide any text? It can't. Also many external models like Claude will simply error out if you send an empty message. You should not send empty messages. Leaving this open for @tjbck to see/triage.
Author
Owner

@Creearc commented on GitHub (Feb 16, 2026):

This is basically intended.

How should the RAG pipeline be able to generate RAG queries if you didnt provide any text? It can't. Also many external models like Claude will simply error out if you send an empty message. You should not send empty messages.

Leaving this open for @tjbck to see/triage.

Sounds reasonable. However, it doesn't work with cases where the model has a system prompt set in the Open WebUI configs that's already enough to handle the attached file without an extra message from the user.

<!-- gh-comment-id:3907863061 --> @Creearc commented on GitHub (Feb 16, 2026): > This is basically intended. > > How should the RAG pipeline be able to generate RAG queries if you didnt provide any text? It can't. Also many external models like Claude will simply error out if you send an empty message. You should not send empty messages. > > Leaving this open for [@tjbck](https://github.com/tjbck) to see/triage. Sounds reasonable. However, it doesn't work with cases where the model has a system prompt set in the Open WebUI configs that's already enough to handle the attached file without an extra message from the user.
Author
Owner

@Creearc commented on GitHub (Feb 16, 2026):

I suggest that fix as a temporal decission: https://github.com/open-webui/open-webui/pull/21450

<!-- gh-comment-id:3907870370 --> @Creearc commented on GitHub (Feb 16, 2026): I suggest that fix as a temporal decission: https://github.com/open-webui/open-webui/pull/21450
Author
Owner

@Classic298 commented on GitHub (Feb 16, 2026):

No the system prompt is it's own message and it's own role

The user message with the file attached has no text because you sent no text.

Therefore the rag pipeline can't work with no text.

<!-- gh-comment-id:3908048950 --> @Classic298 commented on GitHub (Feb 16, 2026): No the system prompt is it's own message and it's own role The user message with the file attached has no text because you sent no text. Therefore the rag pipeline can't work with no text.
Author
Owner

@Creearc commented on GitHub (Feb 16, 2026):

No the system prompt is it's own message and it's own role

The user message with the file attached has no text because you sent no text.

Therefore the rag pipeline can't work with no text.

And why should user have to write text if system prompt contains something like: "Inspect attached file and make a summary"?

<!-- gh-comment-id:3908091894 --> @Creearc commented on GitHub (Feb 16, 2026): > No the system prompt is it's own message and it's own role > > The user message with the file attached has no text because you sent no text. > > Therefore the rag pipeline can't work with no text. And why should user have to write text if system prompt contains something like: "Inspect attached file and make a summary"?
Author
Owner

@Classic298 commented on GitHub (Feb 16, 2026):

because some APIs do not support empty user messages at all (you will get error) and because the system message is not used for RAG query generation - and should not be used for RAG query generation. You have a specific use case, but the general consensus is that using the system prompt for RAG doesnt make sense

"You are an helpful assistant

<30 rules>

..."

using a normal system prompt for RAG makes no sense

@Creearc what you COULD do: is build a filter and inject this message into the empty message text if you want

thats what we do to prevent users from sending empty messages

<!-- gh-comment-id:3908118594 --> @Classic298 commented on GitHub (Feb 16, 2026): because some APIs do not support empty user messages at all (you will get error) and because the system message is not used for RAG query generation - and should not be used for RAG query generation. You have a specific use case, but the general consensus is that using the system prompt for RAG doesnt make sense "You are an helpful assistant <30 rules> ..." using a normal system prompt for RAG makes no sense @Creearc what you COULD do: is build a filter and inject this message into the empty message text if you want thats what we do to prevent users from sending empty messages
Author
Owner

@Creearc commented on GitHub (Feb 16, 2026):

because some APIs do not support empty user messages at all (you will get error)

But in the latest version of Open WebUI, you can send an empty message with a file, and it will go to the LLM with no file context and no message. So I do not understand how it helps to avoid the problem of empty messages for some APIs.

<!-- gh-comment-id:3908161560 --> @Creearc commented on GitHub (Feb 16, 2026): > because some APIs do not support empty user messages at all (you will get error) But in the latest version of Open WebUI, you can send an empty message with a file, and it will go to the LLM with no file context and no message. So I do not understand how it helps to avoid the problem of empty messages for some APIs.
Author
Owner

@Classic298 commented on GitHub (Feb 16, 2026):

@Creearc it doesnt. and that's not open webui's job. Some APIs allow empty messages so Open WebUI should not block empty messages per defaultt

<!-- gh-comment-id:3908206196 --> @Classic298 commented on GitHub (Feb 16, 2026): @Creearc it doesnt. and that's not open webui's job. Some APIs allow empty messages so Open WebUI should not block empty messages per defaultt
Author
Owner

@Creearc commented on GitHub (Feb 16, 2026):

@Creearc it doesnt. and that's not open webui's job. Some APIs allow empty messages so Open WebUI should not block empty messages per defaultt

Ok) Why does Open WebUI clear the file context if the user message is empty? I’m totally confused...

<!-- gh-comment-id:3908228462 --> @Creearc commented on GitHub (Feb 16, 2026): > [@Creearc](https://github.com/Creearc) it doesnt. and that's not open webui's job. Some APIs allow empty messages so Open WebUI should not block empty messages per defaultt Ok) Why does Open WebUI clear the file context if the user message is empty? I’m totally confused...
Author
Owner

@Classic298 commented on GitHub (Feb 16, 2026):

it doesnt clear it - it doesnt create it, since no message is there for rag query generation

<!-- gh-comment-id:3908291369 --> @Classic298 commented on GitHub (Feb 16, 2026): it doesnt clear it - it doesnt create it, since no message is there for rag query generation
Author
Owner

@Steve-Li-1998 commented on GitHub (Feb 16, 2026):

However, not everyone uses RAG, and it seems that only the Claude models do not support image-only prompts. Most importantly, v0.8.2 appears to be unable to correctly handle attachments: even with text prompts, it fails to properly process images

<!-- gh-comment-id:3908780573 --> @Steve-Li-1998 commented on GitHub (Feb 16, 2026): However, not everyone uses RAG, and it seems that only the Claude models do not support image-only prompts. Most importantly, v0.8.2 appears to be unable to correctly handle attachments: even with text prompts, it fails to properly process images
Author
Owner

@Steve-Li-1998 commented on GitHub (Feb 16, 2026):

You can compare my previous screenshots: when the image was successfully transmitted to the API provider (v0.8.1), the prompt_tokens count was 1929. However, in v0.8.2, with the exact same prompt, the prompt_tokens count is only 1117. It looks like only the placeholder for the image was sent to the API provider, which is why the generated content has nothing to do with the image.

<!-- gh-comment-id:3908808382 --> @Steve-Li-1998 commented on GitHub (Feb 16, 2026): You can compare my previous screenshots: when the image was successfully transmitted to the API provider (v0.8.1), the `prompt_tokens` count was 1929. However, in v0.8.2, with the exact same prompt, the `prompt_tokens` count is only 1117. It looks like only the placeholder for the image was sent to the API provider, which is why the generated content has nothing to do with the image.
Author
Owner

@Steve-Li-1998 commented on GitHub (Feb 16, 2026):

I believe that for models with native function-calling support, RAG should be encapsulated within the tool invocation process. For models that do not support this, images can be sent directly to the worker model as-is. If the image contains query instructions and the worker model has visual capabilities, it would then generate the corresponding query commands automatically.

<!-- gh-comment-id:3908836447 --> @Steve-Li-1998 commented on GitHub (Feb 16, 2026): I believe that for models with native function-calling support, RAG should be encapsulated within the tool invocation process. For models that do not support this, images can be sent directly to the worker model as-is. If the image contains query instructions and the worker model has visual capabilities, it would then generate the corresponding query commands automatically.
Author
Owner

@Classic298 commented on GitHub (Feb 16, 2026):

@Steve-Li-1998 there was a bugfix in 0.8.0 where image data was sent twice accidentally, this was fixed

<!-- gh-comment-id:3908921425 --> @Classic298 commented on GitHub (Feb 16, 2026): @Steve-Li-1998 there was a bugfix in 0.8.0 where image data was sent twice accidentally, this was fixed
Author
Owner

@Classic298 commented on GitHub (Feb 16, 2026):

For models that do not support this, images can be sent directly to the worker model as-is

This is still the case and did not change.
You are conflating issues here.

<!-- gh-comment-id:3908923654 --> @Classic298 commented on GitHub (Feb 16, 2026): > For models that do not support this, images can be sent directly to the worker model as-is This is still the case and did not change. You are conflating issues here.
Author
Owner

@Classic298 commented on GitHub (Feb 16, 2026):

RAG should be encapsulated within the tool invocation process

This is what the file context toggle is for - if you have your own RAG tools you can use that. Open WebUI does not provide them by default (yet)

<!-- gh-comment-id:3908927162 --> @Classic298 commented on GitHub (Feb 16, 2026): > RAG should be encapsulated within the tool invocation process This is what the file context toggle is for - if you have your own RAG tools you can use that. Open WebUI does not provide them by default (yet)
Author
Owner

@Steve-Li-1998 commented on GitHub (Feb 16, 2026):

Image Image
<!-- gh-comment-id:3908929843 --> @Steve-Li-1998 commented on GitHub (Feb 16, 2026): <img width="565" height="721" alt="Image" src="https://github.com/user-attachments/assets/56699a57-c169-4aed-a9d2-0e95029e983b" /> <img width="578" height="716" alt="Image" src="https://github.com/user-attachments/assets/a82e367f-2d13-4673-b37d-f2f0ae7868fb" />
Author
Owner

@Steve-Li-1998 commented on GitHub (Feb 16, 2026):

above: v0.8.2
below: v0.8.1

<!-- gh-comment-id:3908935188 --> @Steve-Li-1998 commented on GitHub (Feb 16, 2026): above: v0.8.2 below: v0.8.1
Author
Owner

@Classic298 commented on GitHub (Feb 16, 2026):

interesting.

will take a look for images. this is not intended.

for files, my reasoning stays as above.

<!-- gh-comment-id:3908942390 --> @Classic298 commented on GitHub (Feb 16, 2026): interesting. will take a look for images. this is not intended. for files, my reasoning stays as above.
Author
Owner

@Steve-Li-1998 commented on GitHub (Feb 16, 2026):

It seems that images should be treated as a special type of file.

<!-- gh-comment-id:3908970018 --> @Steve-Li-1998 commented on GitHub (Feb 16, 2026): It seems that images should be treated as a special type of file.
Author
Owner

@Classic298 commented on GitHub (Feb 16, 2026):

they are sent as base64 to the API. They are not treated as a file, and should not be.

<!-- gh-comment-id:3908972208 --> @Classic298 commented on GitHub (Feb 16, 2026): they are sent as base64 to the API. They are not treated as a file, and should not be.
Author
Owner

@Classic298 commented on GitHub (Feb 16, 2026):

should be fixed in https://github.com/open-webui/open-webui/pull/21480

testing wanted

<!-- gh-comment-id:3909095714 --> @Classic298 commented on GitHub (Feb 16, 2026): should be fixed in https://github.com/open-webui/open-webui/pull/21480 testing wanted
Author
Owner

@Classic298 commented on GitHub (Feb 16, 2026):

f1053d94c7

<!-- gh-comment-id:3910387356 --> @Classic298 commented on GitHub (Feb 16, 2026): https://github.com/open-webui/open-webui/commit/f1053d94c7ef7b8b78682dd73586b65a84d202a1
Author
Owner

@systemslocalsplash commented on GitHub (Feb 21, 2026):

This is still happening on v0.8.3 I tried using a json file and it does not work unless I enter a text
is this by design

<!-- gh-comment-id:3937804390 --> @systemslocalsplash commented on GitHub (Feb 21, 2026): This is still happening on v0.8.3 I tried using a json file and it does not work unless I enter a text is this by design
Author
Owner

@systemslocalsplash commented on GitHub (Feb 21, 2026):

@Classic298 This is still happening on v0.8.3 I tried using a json file and it does not work unless I enter a text
is this by design

<!-- gh-comment-id:3937805040 --> @systemslocalsplash commented on GitHub (Feb 21, 2026): @Classic298 This is still happening on v0.8.3 I tried using a json file and it does not work unless I enter a text is this by design
Author
Owner

@Classic298 commented on GitHub (Feb 21, 2026):

@systemslocalsplash read the thread above. This is intended.

<!-- gh-comment-id:3938558721 --> @Classic298 commented on GitHub (Feb 21, 2026): @systemslocalsplash read the thread above. This is intended.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#35016