mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[PR #21118] [CLOSED] fix: skip RAG context injection for native function calling #64792
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/21118
Author: @rbb-dev
Created: 2/3/2026
Status: ❌ Closed
Base:
dev← Head:fix/native-fc-rag-duplication📝 Commits (1)
4b28403fix: skip RAG context injection for native function calling📊 Changes
1 file changed (+1 additions, -1 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+1 -1)📄 Description
When native function calling is enabled, tool results are already sent to the model as function_call_output messages. However, apply_source_context_to_messages() was also injecting these same results as RAG context into user messages, causing token duplication.
The fix adds a check to skip RAG context injection when function_calling is set to "native", consistent with similar checks already present for web_search, memory, and image_generation handlers.
Pull Request Checklist
devbranch.fix:Changelog Entry
Description
Added
Changed
Deprecated
Removed
Fixed
Security
Breaking Changes
Additional Information
Question for Maintainers
Is the RAG context injection after tool execution intentional for native function calling?
If citation formatting is needed, perhaps a lighter approach (metadata only,
not full content) would avoid the token duplication while preserving citations?
Maybe an alternative solution to avoid tool response duplication?
Screenshots or Videos
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.