langchain-ai/deepagents · error · ValueError
{question_type} question {question_text!r} requires a non-em
Error message
{question_type} question {question_text!r} requires a non-empty 'choices' list What it means
`_validate_question` raises ValueError when a choice-type question (multiple choice / multi-select) has an empty or missing `choices` list. A choice question without options cannot be rendered, so a non-empty choices list is required.
Source
Thrown at libs/code/deepagents_code/_ask_user_types.py:262
Args:
question: The parsed `Question` to check.
Returns:
The same `question`, unchanged.
Raises:
ValueError: If the question violates one of the rules above.
"""
question_type = question["type"]
question_text = question["question"]
choices = question.get("choices")
if question_type in CHOICE_QUESTION_TYPES:
if not choices:
msg = (
f"{question_type} question {question_text!r} requires a "
f"non-empty 'choices' list"
)
raise ValueError(msg)
elif choices:
msg = f"{question_type} question {question_text!r} must not define 'choices'"
raise ValueError(msg)
return question
class Question(TypedDict):
"""A question to ask the user."""
question: Annotated[
str,
AfterValidator(_validate_question_text),
Field(description="The question text to display.", min_length=1),
]
type: Annotated[
QuestionType,
Field(View on GitHub (pinned to a1af029e6e)
Solutions
- Provide at least one (validated) choice for every choice-type question
- If options are computed at runtime, fall back to a free-text question type when the list is empty
- Check the model's tool-call arguments — an omitted `choices` key means the schema wasn't followed; tighten the tool description
- Validate upstream data before constructing the question to avoid runtime ValueError
Example fix
# before
{"question_type": "multiple_choice", "text": "Pick a DB?", "choices": []}
# after
{"question_type": "multiple_choice", "text": "Pick a DB?", "choices": [{"value": "postgres"}, {"value": "mysql"}]} Defensive patterns
Strategy: validation
Validate before calling
if q["question_type"] in CHOICE_QUESTION_TYPES and not q.get("choices"):
raise ValueError(f"{q['question_type']} question requires non-empty 'choices'") Type guard
def has_choices(q: dict) -> bool:
return not (q.get("question_type") in CHOICE_QUESTION_TYPES and not q.get("choices")) Try / catch
try:
ask_user(questions=questions)
except ValueError as exc:
if "requires a non-empty 'choices' list" in str(exc):
# regenerate the question with options or downgrade to free-text
...
else:
raise Prevention
- Never submit a choice-type question without at least one validated choice
- Fall back to a free-text question when the option list computes to empty
- Reinforce the ask_user tool schema/description so the model includes choices
- Build questions through one helper that enforces invariants instead of raw dicts
When it happens
Trigger: An ask_user call with `question_type` in CHOICE_QUESTION_TYPES and `choices` set to `[]`, `None`, or omitted — raised at libs/code/deepagents_code/_ask_user_types.py:262.
Common situations: An LLM omitting the choices array in a tool call; code building questions from a dynamic option list that ended up empty (e.g. no available environments); template scaffolding with a placeholder empty list never filled.
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
- choice has a blank 'value': {choice!r}
- question text must not be blank
- {question_type} question {question_text!r} must not define '
- ask_user requires at least one question
- 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/8b659f55675a058c.
Report an issue: GitHub.