langchain-ai/deepagents · error · ValueError
ask_user requires at least one question
Error message
ask_user requires at least one question
What it means
`_validate_questions` raises ValueError when the ask_user call receives an empty question list. The ask_user tool exists to collect answers, so at least one question must be submitted.
Source
Thrown at libs/code/deepagents_code/_ask_user_types.py:368
Per-question rules live on `ValidatedQuestion`; this covers the one rule
about the list itself. Attached both to the tool's `questions` parameter
and to `AskUserRequest.questions`, so the client re-validation boundary
rejects an empty list too — `AskUserMenu([])` would otherwise build a
titled prompt with no question widgets and nothing focusable.
Args:
questions: The parsed `questions` argument to check.
Returns:
The same `questions`, unchanged.
Raises:
ValueError: If the list is empty.
"""
if not questions:
msg = "ask_user requires at least one question"
raise ValueError(msg)
return questions
class AskUserRequest(TypedDict):
"""Request payload sent via interrupt when asking the user questions."""
type: Literal["ask_user"]
"""Discriminator tag, always `'ask_user'`."""
questions: Annotated[list[ValidatedQuestion], AfterValidator(_validate_questions)]
"""Questions to present to the user.
`ValidatedQuestion` rather than `Question`, and carrying
`_validate_questions`, so every rule the tool applies also applies where
`tui.textual_adapter` re-validates this payload. A choice question with no
`choices` would otherwise reach the client and degrade to a text box, and
an empty list would render a prompt with no questions in it.
"""View on GitHub (pinned to a1af029e6e)
Solutions
- Always pass at least one validated question to ask_user
- If questions are built dynamically, skip the ask_user call entirely when the list is empty instead of sending it
- Check the model's tool-call arguments for an omitted/empty `questions` array and reinforce the tool description
- Guard the call site with a length check before invoking the tool
Example fix
# before
ask_user(questions=[])
# after
questions = build_questions(context)
if questions:
ask_user(questions=questions)
else:
proceed_without_input() Defensive patterns
Strategy: validation
Validate before calling
if not questions:
raise ValueError("ask_user requires at least one question") Type guard
def has_questions(questions: list) -> bool:
return len(questions) > 0 Try / catch
try:
ask_user(questions=questions)
except ValueError as exc:
if "requires at least one question" in str(exc):
# skip asking and proceed with defaults
...
else:
raise Prevention
- Guard ask_user call sites with a non-empty check on the questions list
- Skip the ask_user tool call entirely when dynamic question building yields nothing
- Enforce minItems=1 on the questions array in the tool schema where possible
- Add a unit test covering the empty-questions path of your question builder
When it happens
Trigger: An agent invoking `ask_user` with `questions: []`, or code building an `AskUserRequest` from a dynamically filtered list that ended up empty — raised at libs/code/deepagents_code/_ask_user_types.py:368.
Common situations: An LLM emitting an empty questions array in the tool call; logic that filters questions by some condition and passes the (possibly empty) remainder; template code with a loop that appends nothing before submitting.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- question text must not be blank
- choice has a blank 'value': {choice!r}
- {question_type} question {question_text!r} requires a non-em
- {question_type} question {question_text!r} must not define '
- Could not parse embedded resource block. Block expected eith
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/ce18a051b498a08a.
Report an issue: GitHub.