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:
Classic298 2026-10-20 20:33:10 +02:00 • committed by GitHub
parent 1d0b782719
commit 794e57cf7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -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 = []

View file

@ -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 = []