From 794e57cf7ed29e0bf00a66a825c1d0b9682845b4 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Tue, 20 Oct 2026 20:33:10 +0200 Subject: [PATCH] fix: misleading ask_user error when questions are not sent as a list (#32727) When a model sent the ask_user questions as anything other than a list, for example a JSON-encoded string, the tool answered "ask_user requires 1-3 questions." The model had sent the right number of questions, so it did not understand the error and often repeated the same call in a loop. It now gets a separate error saying the questions must be an array of question objects, and the count error only appears when the count is actually wrong. Fixes #32662 --- backend/open_webui/tools/builtin.py | 4 +++- backend/open_webui/utils/ask_user.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/tools/builtin.py b/backend/open_webui/tools/builtin.py index dcbdfe5201..dd1c38fdd7 100644 --- a/backend/open_webui/tools/builtin.py +++ b/backend/open_webui/tools/builtin.py @@ -539,7 +539,9 @@ async def ask_user( :return: JSON with status and answers keyed by question id """ try: - if not isinstance(questions, list) or not 1 <= len(questions) <= 3: + if not isinstance(questions, list): + raise ValueError('ask_user questions must be an array of question objects.') + if not 1 <= len(questions) <= 3: raise ValueError('ask_user requires 1-3 questions.') normalized_questions = [] diff --git a/backend/open_webui/utils/ask_user.py b/backend/open_webui/utils/ask_user.py index 14f5da6ad0..94bc648ef2 100644 --- a/backend/open_webui/utils/ask_user.py +++ b/backend/open_webui/utils/ask_user.py @@ -24,7 +24,9 @@ def get_ask_user_tool_calls(tool_calls: list[dict]) -> tuple[list[dict], str | N def normalize_ask_user_request(arguments: dict) -> dict: questions = arguments.get('questions') - if not isinstance(questions, list) or not 1 <= len(questions) <= 3: + if not isinstance(questions, list): + raise ValueError('ask_user questions must be an array of question objects.') + if not 1 <= len(questions) <= 3: raise ValueError('ask_user requires 1-3 questions.') normalized_questions = []