mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-14 05:02:01 -06:00
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
This commit is contained in:
@@ -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 = []
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
Reference in New Issue
Block a user