Skip to content

fix: validation error messages for invalid participants in BaseGroupChat#7715

Open
AmSach wants to merge 1 commit into
microsoft:mainfrom
AmSach:fix/validation-error-for-invalid-participants
Open

fix: validation error messages for invalid participants in BaseGroupChat#7715
AmSach wants to merge 1 commit into
microsoft:mainfrom
AmSach:fix/validation-error-for-invalid-participants

Conversation

@AmSach

@AmSach AmSach commented May 19, 2026

Copy link
Copy Markdown

Fixed the bug described in issue #7580. Here's what was wrong and how I fixed it:

What was broken:
When invalid participants (None, wrong types, or lists containing non-agent objects) were passed to RoundRobinGroupChat (or any BaseGroupChat subclass), the constructor raised raw low-level Python errors like TypeError: object of type 'NoneType' has no len(), AttributeError: 'str' object has no attribute 'name', instead of a clear validation message.

How I fixed it:
Added explicit input validation at the top of BaseGroupChat.__init__ that checks:

  1. participants is not None → raises TypeError
  2. participants is a list or tuple → raises TypeError if not
  3. participants is non-empty → raises ValueError if empty
  4. All items are ChatAgent or Team instances → raises TypeError with index and actual type name if not

This replaces opaque internal errors with clear, actionable messages that point users directly to the problem.

Testing:
Verified all 5 error cases from the issue now produce descriptive errors:

  • RoundRobinGroupChat(participants=None)TypeError: participants must be a non-empty sequence of ChatAgent or Team instances.
  • RoundRobinGroupChat(participants="not a list")TypeError: participants must be a list or tuple of ChatAgent or Team instances.
  • RoundRobinGroupChat(participants=42)TypeError: participants must be a list or tuple of ChatAgent or Team instances.
  • RoundRobinGroupChat(participants=[])ValueError: At least one participant is required.
  • RoundRobinGroupChat(participants=[UserProxyAgent(name="valid"), "bad"])TypeError: participants[1] must be a ChatAgent or Team instance, got str.

Files changed:

  • python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py — added 9 lines of validation

Link to issue: #7580

…upChat

Before this fix, passing invalid participants (None, wrong types, bad list items)
to RoundRobinGroupChat caused raw AttributeError/TypeError from internal code.

After this fix, BaseGroupChat.__init__ validates participants upfront:
- None -> TypeError with descriptive message
- Wrong type (not list/tuple) -> TypeError
- Empty list -> ValueError
- Non-agent items -> TypeError with index and actual type shown

Fixes microsoft#7580
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant