{"record":{"id":"6ddf5bf1f0cfa69d","repo":"langchain-ai/deepagents","slug":"question-text-must-not-be-blank","errorCode":null,"errorMessage":"question text must not be blank","messagePattern":"question text must not be blank","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/_ask_user_types.py","lineNumber":184,"sourceCode":"    annotation it runs before `min_length=1`, which therefore never rejects\n    anything — that constraint is kept only because it is what puts\n    `minLength: 1` in the JSON schema the model reads. Swapping the two moves\n    the empty-string rejection onto `min_length` and changes the error the\n    model sees from this function's message to `string_too_short`. A string\n    like `\"   \"` would render as a visually blank prompt.\n\n    Args:\n        text: The parsed `question` text to check.\n\n    Returns:\n        The same `text`, unchanged.\n\n    Raises:\n        ValueError: If `text` has no non-whitespace character.\n    \"\"\"\n    if not text.strip():\n        msg = \"question text must not be blank\"\n        raise ValueError(msg)\n    return text\n\n\ndef _validate_choice(choice: Choice) -> Choice:\n    \"\"\"Reject a choice whose `value` is blank.\n\n    A blank value would render as an unlabelled option the user can select but\n    whose answer reads as \"no answer\".\n\n    Attached to the item annotation inside `Question.choices`, not to `Choice`\n    itself, so `TypeAdapter(Choice)` does not apply it.\n\n    Callers must pass a parsed `Choice`. A missing `value` never reaches here —\n    it is a required key, so pydantic rejects it as `choices.N.value: Field\n    required` before the choice-level validators run. On a raw dict this would\n    raise `KeyError`, which is not a `ValidationError` and would halt the run.\n\n    Args:","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/_ask_user_types.py#L166-L202","documentation":"`_validate_question_text` in libs/code/deepagents_code/_ask_user_types.py raises ValueError when an ask_user question's `text` is empty or whitespace-only. Question text must contain at least one non-whitespace character for the prompt UI to render meaningfully.","triggerScenarios":"An agent calling the `ask_user` tool with a question whose `text` field is `\"\"` or `\"   \"`, or building an `AskUserRequest` programmatically with blank text — validation runs at libs/code/deepagents_code/_ask_user_types.py:184.","commonSituations":"An LLM generating a question with an empty text field from a malformed tool call; template code interpolating a variable that is empty; tests or scripts constructing Question dicts manually with omitted/blank text.","solutions":["Set a non-empty, descriptive `text` string on the question before calling ask_user","If text is generated dynamically, add a fallback default when the value strips to empty","Check the model's tool-call arguments for truncated or dropped `text` values and strengthen the tool description/example","Wrap construction in validation that re-prompts the model when text is blank"],"exampleFix":"# before\n{\"question_type\": \"multiple_choice\", \"text\": \"  \", \"choices\": [...]}\n# after\n{\"question_type\": \"multiple_choice\", \"text\": \"Which database should we migrate to?\", \"choices\": [...]}","handlingStrategy":"validation","validationCode":"if not question.get(\"text\", \"\").strip():\n    raise ValueError(\"question text must not be blank\")","typeGuard":"def has_question_text(q: dict) -> bool:\n    return isinstance(q.get(\"text\"), str) and bool(q[\"text\"].strip())","tryCatchPattern":"try:\n    ask_user(questions=questions)\nexcept ValueError as exc:\n    if \"question text must not be blank\" in str(exc):\n        questions = [q for q in questions if q.get(\"text\", \"\").strip()]\n        if questions:\n            ask_user(questions=questions)\n    else:\n        raise","preventionTips":["Trim and non-empty-check question text before constructing Question dicts","Give the model clear tool-call examples showing populated text fields","Reject blank text at question-construction time, not at ask_user time","Avoid interpolating possibly-empty variables directly into question text"],"tags":["validation","ask-user","dcode","valueerror"],"backgroundTag":"schema-validation-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}