{"record":{"id":"80ed95af73623c26","repo":"microsoft/autogen","slug":"task-list-cannot-be-empty-80ed95","errorCode":null,"errorMessage":"Task list cannot be empty.","messagePattern":"Task list cannot be empty\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py","lineNumber":465,"sourceCode":"\n                # This will raise a cancellation error.\n                await run_task\n\n\n            asyncio.run(main())\n\n        \"\"\"\n        # Create the messages list if the task is a string or a chat message.\n        messages: List[BaseChatMessage] | None = None\n        if task is None:\n            pass\n        elif isinstance(task, str):\n            messages = [TextMessage(content=task, source=\"user\")]\n        elif isinstance(task, BaseChatMessage):\n            messages = [task]\n        elif isinstance(task, list):\n            if not task:\n                raise ValueError(\"Task list cannot be empty.\")\n            messages = []\n            for msg in task:\n                if not isinstance(msg, BaseChatMessage):\n                    raise ValueError(\"All messages in task list must be valid BaseChatMessage types\")\n                messages.append(msg)\n        else:\n            raise ValueError(\"Task must be a string, a BaseChatMessage, or a list of BaseChatMessage.\")\n        # Check if the messages types are registered with the message factory.\n        if messages is not None:\n            for msg in messages:\n                if not self._message_factory.is_registered(msg.__class__):\n                    raise ValueError(\n                        f\"Message type {msg.__class__} is not registered with the message factory. \"\n                        \"Please register it with the message factory by adding it to the \"\n                        \"custom_message_types list when creating the team.\"\n                    )\n\n        if self._is_running:","sourceCodeStart":447,"sourceCodeEnd":483,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py#L447-L483","documentation":"run() / run_stream() reject an empty task list. An empty list is treated as a user-supplied task with zero messages, which is indistinguishable from a configuration bug, so it fails fast instead of silently starting a no-op run.","triggerScenarios":"Calling await team.run(task=[]) or team.run_stream(task=[]) — an empty Python list passed as the task argument.","commonSituations":"Task lists built dynamically (e.g. filtered message history) that end up empty; passing task=[] intending 'no task' — use task=None for that.","solutions":["Use task=None (or omit the argument) when you want to resume/continue without a new task.","Otherwise include at least one message: task=[TextMessage(content=\"Start\", source=\"user\")].","Guard dynamic lists: task = msgs or None."],"exampleFix":"# before\nawait team.run(task=[])  # ValueError\n\n# after\nawait team.run(task=None)  # continue without a new task","handlingStrategy":"validation","validationCode":"task = task or None  # normalize empty list to 'no task'\nawait team.run(task=task)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use task=None to mean 'continue without new input'; never an empty list.","Guard dynamically filtered message lists: msgs if msgs else None."],"tags":["python","autogen","group-chat","task","validation"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}