{"record":{"id":"8b659f55675a058c","repo":"langchain-ai/deepagents","slug":"question-type-question-question-text-r-require","errorCode":null,"errorMessage":"{question_type} question {question_text!r} requires a non-empty 'choices' list","messagePattern":"(.+?) question (.+?) requires a non-empty 'choices' list","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/_ask_user_types.py","lineNumber":262,"sourceCode":"    Args:\n        question: The parsed `Question` to check.\n\n    Returns:\n        The same `question`, unchanged.\n\n    Raises:\n        ValueError: If the question violates one of the rules above.\n    \"\"\"\n    question_type = question[\"type\"]\n    question_text = question[\"question\"]\n    choices = question.get(\"choices\")\n    if question_type in CHOICE_QUESTION_TYPES:\n        if not choices:\n            msg = (\n                f\"{question_type} question {question_text!r} requires a \"\n                f\"non-empty 'choices' list\"\n            )\n            raise ValueError(msg)\n    elif choices:\n        msg = f\"{question_type} question {question_text!r} must not define 'choices'\"\n        raise ValueError(msg)\n    return question\n\n\nclass Question(TypedDict):\n    \"\"\"A question to ask the user.\"\"\"\n\n    question: Annotated[\n        str,\n        AfterValidator(_validate_question_text),\n        Field(description=\"The question text to display.\", min_length=1),\n    ]\n\n    type: Annotated[\n        QuestionType,\n        Field(","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/_ask_user_types.py#L244-L280","documentation":"`_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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\n{\"question_type\": \"multiple_choice\", \"text\": \"Pick a DB?\", \"choices\": []}\n# after\n{\"question_type\": \"multiple_choice\", \"text\": \"Pick a DB?\", \"choices\": [{\"value\": \"postgres\"}, {\"value\": \"mysql\"}]}","handlingStrategy":"validation","validationCode":"if q[\"question_type\"] in CHOICE_QUESTION_TYPES and not q.get(\"choices\"):\n    raise ValueError(f\"{q['question_type']} question requires non-empty 'choices'\")","typeGuard":"def has_choices(q: dict) -> bool:\n    return not (q.get(\"question_type\") in CHOICE_QUESTION_TYPES and not q.get(\"choices\"))","tryCatchPattern":"try:\n    ask_user(questions=questions)\nexcept ValueError as exc:\n    if \"requires a non-empty 'choices' list\" in str(exc):\n        # regenerate the question with options or downgrade to free-text\n        ...\n    else:\n        raise","preventionTips":["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"],"tags":["validation","ask-user","dcode","valueerror","choices"],"backgroundTag":"schema-validation-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}