From 9475106560c8cfee4de5f789fe6f44a5a23e6be0 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 23 Nov 2026 16:11:54 +0100 Subject: [PATCH] fix: reply after tools stop can come back empty with some models (#34759) When a chat hits the tool call limit, or tool use stops because the same call keeps failing or a reply is cut off in the middle of a call, Open WebUI asks the model for one last answer. The instruction to stop and answer was merged into the system prompt at the very top of the conversation, so some models (Gemma 4 on vLLM, for example) kept trying to call tools and returned an empty reply. It is now sent as the last message, after the tool results, so the model reads it right before answering. The start of that last request also stays identical to the earlier ones, so provider prompt caching keeps working for it. Fixes #34750 --- backend/open_webui/utils/tool_calling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/open_webui/utils/tool_calling.py b/backend/open_webui/utils/tool_calling.py index a16513e3e3..7a7bb9d6f1 100644 --- a/backend/open_webui/utils/tool_calling.py +++ b/backend/open_webui/utils/tool_calling.py @@ -337,5 +337,5 @@ def final_answer_payload(payload): return { **payload, 'tool_choice': 'none', - 'messages': [*payload.get('messages', []), {'role': 'system', 'content': FINAL_ANSWER_PROMPT}], + 'messages': [*payload.get('messages', []), {'role': 'user', 'content': FINAL_ANSWER_PROMPT}], }