mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[GH-ISSUE #21167] issue: user message is duplicated for RAG queries #58075
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 @Simon-Stone on GitHub (Feb 4, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/21167
Check Existing Issues
Installation Method
Docker
Open WebUI Version
v0.7.2
Ollama Version (if applicable)
No response
Operating System
MacOS
Browser (if applicable)
No response
Confirmation
README.md.Expected Behavior
The fully rendered RAG template contains the user query at the end. The rendered template should therefore replace the user message.
Actual Behavior
The rendered RAG template is preprended to the user message, so the user message contents are repeated once inside the <user_query> tags and once at the end.
Steps to Reproduce
Logs & Screenshots
See #19098.
Additional Information
The duplication of the user message after the RAG template is still an issue. I traced this through these two functions:
The RAG template is applied in
apply_source_context_to_messagescallingadd_or_update_user_message():6cd35b185d/backend/open_webui/utils/middleware.py (L808-L814)I assume the programmer's attention was to overwrite the user message instead of appending to it when setting
append=False. Howevere, that parameter only changes the order of original and new content:6cd35b185d/backend/open_webui/utils/misc.py (L247-L260)That's why the original user message still appears at the end, even though the rendered RAG template should replace it entirely.
Not sure what the original intention of
appendwas, since it's undocumented. If it's current behavior is as intended, I would suggest adding a functionreplace_user_messagesimilar to:6cd35b185d/backend/open_webui/utils/misc.py (L263-L268)@owui-terminator[bot] commented on GitHub (Feb 4, 2026):
🔍 Similar Issues Found
I found some existing issues that might be related to this one. Please check if any of these are duplicates or contain helpful solutions:
#20661 issue: RAG threshold and chat file include bug
by n4gY1 • Jan 14, 2026 •
bug#20558 issue: RAG Knowledge file when modify/update, older data is available
by n4gY1 • Jan 10, 2026 •
bug#19098 issue: Prompt & context duplication when RAG template is used
by matiboux • Nov 11, 2025 •
bug#20033 issue: RAG not working when file uploaded through chat
by abhishek-paradkar-sndk • Dec 18, 2025 •
bug#19281 issue: RAG Template applied with "Bypass Embedding and Retrieval" enabled
by lucyknada • Nov 19, 2025 •
bugShow 2 more related issues
#19825 Image Generation and Web Search trigger on every message
by bcnation • Dec 08, 2025 •
bug#19752 issue: minor UI Bug: knowledge sharing
by mahenning • Dec 04, 2025 •
bug,confirmed issue💡 Tips:
This comment was generated automatically by a bot. Please react with a 👍 if this comment was helpful, or a 👎 if it was not.
@tjbck commented on GitHub (Feb 5, 2026):
You can edit/modify the template.