mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-17 08:21:12 -05:00
[PR #22272] [CLOSED] fix: prevent duplicate RAG prompt when file upload and tool sources combine #81451
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?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22272
Author: @Classic298
Created: 3/5/2026
Status: ❌ Closed
Base:
dev← Head:fix/rag-prompt-duplication📝 Commits (1)
d858fd9fix: prevent duplicate RAG prompt when file upload and tool sources combine📊 Changes
1 file changed (+98 additions, -29 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+98 -29)📄 Description
When a user uploads a file AND the model uses a native tool that returns citation sources (e.g. fetch_url, query_knowledge_bases), the RAG system prompt was injected twice — once for file sources in process_chat_payload and again for tool sources in the streaming handler.
Root cause: the deduplication snapshots (user_message and original_system_content) were captured after the first RAG injection, so restoring to them did not undo the already-injected template.
Fix:
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.