From b00745c8d08918649fe48adc8849dac1f55ad147 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 28 Sep 2026 05:59:20 +0200 Subject: [PATCH] fix: approved tool results are lost and approved tools can run twice (#31502) With tool approval set to ask, the result of an approved tool call was dropped from the chat once the reply finished, so the model no longer saw it in later turns. When the model then asked for a second tool, the first call went back to waiting for approval, and approving it again ran the tool a second time. Approved results now stay in the chat and each tool runs once. Related to #31499 --- backend/open_webui/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 9573d1df91..ecba6407f3 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -1644,7 +1644,8 @@ async def chat_completion( async def process_chat(request, form_data, user, metadata, model, tasks=None): try: ctx = None - if metadata.get('assistant_message_id'): + # Saved chats load the message after approved tool calls run, so their results are kept + if metadata.get('assistant_message_id') and not is_saved_chat_id(metadata.get('chat_id')): ctx = await build_chat_response_context(request, form_data, user, model, metadata, tasks, []) form_data, metadata, events = await process_chat_payload(request, form_data, user, metadata, model)