mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-05 18:38:17 -05:00
[PR #19122] [MERGED] fix: Duplicate instructions in tool selection calling prompt #40727
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/19122
Author: @matiboux
Created: 11/11/2025
Status: ✅ Merged
Merged: 11/11/2025
Merged by: @tjbck
Base:
dev← Head:fix/tool-selection-user-message📝 Commits (2)
dccadd3Fix duplicated query prefix in user prompt for function callingc4b4e18Fix duplicated last user message in prompt for function calling📊 Changes
1 file changed (+6 additions, -2 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+6 -2)📄 Description
Pull Request Checklist
Before submitting, make sure you've checked the following:
devbranch. Not targeting thedevbranch will lead to immediate closure of the PR.Changelog Entry
Description
backend/open_webui/utils/middleware.pyto avoid duplication and improve clarity when preparing messages for tools selection and calling. The main changes focus on removing redundant instructions and user messages in the prompt.Added
None.
Changed
get_tools_function_calling_payloadinchat_completion_tools_handlerinbackend/open_webui/utils/middleware.pyto remove duplicated "Query:" prefix and duplicated user message in the prompt used for tools selection and calling.get_tools_function_calling_payloadinchat_completion_tools_handlerinbackend/open_webui/utils/middleware.pyto omit the chat history if only the user query (last user message) is present.Deprecated
None.
Removed
None.
Fixed
None.
Security
None.
Breaking Changes
None.
Additional Information
This PR addresses & fixes #19121.
Updated prompts were manually tested and verified using a proxy OpenAI-compatible proxy API to inspect system & user messages.
Tool Selection Request prompt with changes from this PR:
In a conversation with chat history, the user message is sent like this in the Tool Selection Request prompt:
Screenshots or Videos
None.
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.