microsoft/autogen · error · ValueError

Task list cannot be empty.

Error message

Task list cannot be empty.

What it means

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.

Source

Thrown at python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py:465

                # This will raise a cancellation error.
                await run_task


            asyncio.run(main())

        """
        # Create the messages list if the task is a string or a chat message.
        messages: List[BaseChatMessage] | None = None
        if task is None:
            pass
        elif isinstance(task, str):
            messages = [TextMessage(content=task, source="user")]
        elif isinstance(task, BaseChatMessage):
            messages = [task]
        elif isinstance(task, list):
            if not task:
                raise ValueError("Task list cannot be empty.")
            messages = []
            for msg in task:
                if not isinstance(msg, BaseChatMessage):
                    raise ValueError("All messages in task list must be valid BaseChatMessage types")
                messages.append(msg)
        else:
            raise ValueError("Task must be a string, a BaseChatMessage, or a list of BaseChatMessage.")
        # Check if the messages types are registered with the message factory.
        if messages is not None:
            for msg in messages:
                if not self._message_factory.is_registered(msg.__class__):
                    raise ValueError(
                        f"Message type {msg.__class__} is not registered with the message factory. "
                        "Please register it with the message factory by adding it to the "
                        "custom_message_types list when creating the team."
                    )

        if self._is_running:

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Use task=None (or omit the argument) when you want to resume/continue without a new task.
  2. Otherwise include at least one message: task=[TextMessage(content="Start", source="user")].
  3. Guard dynamic lists: task = msgs or None.

Example fix

# before
await team.run(task=[])  # ValueError

# after
await team.run(task=None)  # continue without a new task
Defensive patterns

Strategy: validation

Validate before calling

task = task or None  # normalize empty list to 'no task'
await team.run(task=task)

Prevention

When it happens

Trigger: Calling await team.run(task=[]) or team.run_stream(task=[]) — an empty Python list passed as the task argument.

Common situations: Task lists built dynamically (e.g. filtered message history) that end up empty; passing task=[] intending 'no task' — use task=None for that.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/80ed95af73623c26. Report an issue: GitHub.