{"record":{"id":"faba10e164b6fd38","repo":"langchain-ai/deepagents","slug":"question-type-question-question-text-r-must-no","errorCode":null,"errorMessage":"{question_type} question {question_text!r} must not define 'choices'","messagePattern":"(.+?) question (.+?) must not define 'choices'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/_ask_user_types.py","lineNumber":265,"sourceCode":"    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(\n            description=(\n                \"Question type. 'text' for free-form input, 'multiple_choice' for \"\n                \"picking exactly one predefined option, 'multi_select' for picking \"","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/_ask_user_types.py#L247-L283","documentation":"The counterpart of error 17: `_validate_question` raises ValueError when a NON-choice question type (e.g. free text) defines a `choices` list. Only choice-type questions may carry choices; extra ones on free-text questions are rejected.","triggerScenarios":"An ask_user question whose `question_type` is not in CHOICE_QUESTION_TYPES but whose dict includes a non-empty `choices` key — raised at libs/code/deepagents_code/_ask_user_types.py:265.","commonSituations":"An LLM adding a `choices` field to every question regardless of type; reusing one question-building helper that always attaches choices; a `question_type` typo that makes a choice question classify as free text.","solutions":["Remove the `choices` key from free-text questions","Verify `question_type` is spelled correctly so choice questions are recognized as choice types","If the agent generates the question dict, constrain the schema/examples so choices only appear for choice types","Move the option list into a `multiple_choice` or `multi_select` question instead of decorating a text question"],"exampleFix":"// before\n{\"question_type\": \"text\", \"text\": \"Describe the bug?\", \"choices\": [{\"value\": \"a\"}]}\n// after\n{\"question_type\": \"text\", \"text\": \"Describe the bug?\"}","handlingStrategy":"validation","validationCode":"if q[\"question_type\"] not in CHOICE_QUESTION_TYPES and q.get(\"choices\"):\n    raise ValueError(f\"{q['question_type']} question must not define 'choices'\")","typeGuard":"def choices_match_type(q: dict) -> bool:\n    is_choice = q.get(\"question_type\") in CHOICE_QUESTION_TYPES\n    return is_choice == bool(q.get(\"choices\"))","tryCatchPattern":"try:\n    ask_user(questions=questions)\nexcept ValueError as exc:\n    if \"must not define 'choices'\" in str(exc):\n        questions = [{k: v for k, v in q.items() if k != \"choices\"} for q in questions]\n        ask_user(questions=questions)\n    else:\n        raise","preventionTips":["Attach `choices` only to multiple_choice/multi_select questions","Check question_type spelling so choice questions classify correctly","Use a single question-construction helper that keys extra fields off the type","Review LLM tool-call args for stray choices fields on text questions"],"tags":["validation","ask-user","dcode","valueerror","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}