autogen - ✅(Solved) Fix RoundRobinGroupChat raises raw AttributeError/TypeError for invalid participants instead of a clear validation error [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
microsoft/autogen#7580Fetched 2026-04-16 06:37:21
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
cross-referenced ×1issue_type_added ×1labeled ×1referenced ×1

Error Message

The constructor should reject these invalid inputs with a clear validation error, for example: This is not a request to accept these inputs. The issue is only about error handling: invalid user input currently leaks internal AttributeError/TypeError instead of a clear validation message.

Fix Action

Fixed

PR fix notes

PR #7581: fix: Add input validation for participants in BaseGroupChat (#7580)

Description (problem / solution / changelog)

Good day,

This PR adds clear input validation for the participants parameter in BaseGroupChat (and consequently RoundRobinGroupChat), addressing issue #7580.

Problem

Previously, when invalid inputs were passed to RoundRobinGroupChat(participants=...):

  • NoneTypeError: object of type 'NoneType' has no len()
  • "not a list"AttributeError: 'str' object has no attribute 'name'
  • [UserProxyAgent(...), "bad"]AttributeError: 'str' object has no attribute 'name'

Solution

Added validation in BaseGroupChat.__init__ to check:

  1. participants is not None
  2. participants can be converted to a list
  3. The list is not empty
  4. Each item is a ChatAgent or Team instance

Now invalid inputs raise clear error messages:

  • TypeError: participants must be a non-empty sequence of ChatAgent or Team instances.
  • TypeError: participants must be a non-empty sequence of ChatAgent or Team instances, but found str at index 0.

Thank you for your work on this project. I hope this small fix is helpful. Please let me know if there's anything to adjust.

Warmly, RoomWithOutRoof

Changed files

  • python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py (modified, +15/-3)
  • python/packages/autogen-ext/src/autogen_ext/code_executors/jupyter/_jupyter_code_executor.py (modified, +11/-1)
RAW_BUFFERClick to expand / collapse

What happened?

Describe the bug Hi, I noticed that RoundRobinGroupChat does not seem to validate the type of the participants argument before using it.

When participants is accidentally set to None, a string, an integer, or a list containing a non-agent object, the constructor raises low-level Python errors such as:

  • TypeError: object of type 'NoneType' has no len()
  • TypeError: object of type 'int' has no len()
  • AttributeError: 'str' object has no attribute 'name'

I understand these are invalid inputs, but they are realistic user mistakes. It would be much easier to debug if AutoGen raised a clear TypeError or ValueError explaining that participants must be a non-empty list/sequence of ChatAgent instances.

To Reproduce from autogen_agentchat.agents import UserProxyAgent from autogen_agentchat.teams import RoundRobinGroupChat

Case 1: participants is None

RoundRobinGroupChat(participants=None)

Case 2: participants is not a sequence of agents

RoundRobinGroupChat(participants="not a list")

Case 3: participants contains a non-agent object

RoundRobinGroupChat(participants=[UserProxyAgent(name="valid_user"), "bad"])

Expected behavior The constructor should reject these invalid inputs with a clear validation error, for example:

TypeError: participants must be a non-empty sequence of ChatAgent instances

or a similar ValueError explaining which item is invalid.

Actual behavior The constructor raises internal implementation errors:

RoundRobinGroupChat(participants=None) -> TypeError: object of type 'NoneType' has no len()

RoundRobinGroupChat(participants="not a list") -> AttributeError: 'str' object has no attribute 'name'

RoundRobinGroupChat(participants=[UserProxyAgent(name="valid_user"), "bad"]) -> AttributeError: 'str' object has no attribute 'name'

** Environment** Package: autogen-agentchat Observed with the local AutoGen checkout / current environment. Python: 3.13

Additional context This is not a request to accept these inputs. The issue is only about error handling: invalid user input currently leaks internal AttributeError/TypeError instead of a clear validation message.

Which packages was the bug in?

Python AgentChat (autogen-agentchat>=0.4.0)

AutoGen library version.

Python dev (main branch)

Other library version.

No response

Model used

No response

Model provider

None

Other model provider

No response

Python version

3.10

.NET version

None

Operating system

MacOS

extent analysis

TL;DR

The RoundRobinGroupChat constructor should be modified to validate the participants argument and raise a clear TypeError or ValueError for invalid inputs.

Guidance

  • Add input validation to the RoundRobinGroupChat constructor to check if participants is a non-empty list or sequence of ChatAgent instances.
  • Raise a TypeError or ValueError with a clear error message when invalid inputs are detected, such as participants being None, a string, an integer, or a list containing non-agent objects.
  • Consider using isinstance() to check if each participant is an instance of ChatAgent.
  • Update the constructor to handle these validation errors and provide informative error messages.

Example

def __init__(self, participants):
    if not isinstance(participants, (list, tuple)) or not all(isinstance(p, ChatAgent) for p in participants):
        raise TypeError("participants must be a non-empty sequence of ChatAgent instances")
    if not participants:
        raise ValueError("participants cannot be empty")
    # ... rest of the constructor implementation ...

Notes

This solution assumes that ChatAgent is a base class or interface that all valid participant objects should inherit from or implement. The isinstance() checks can be adjusted if the actual implementation uses a different approach to identify valid participant objects.

Recommendation

Apply the suggested workaround by modifying the RoundRobinGroupChat constructor to include input validation and clear error handling. This will improve the robustness and usability of the RoundRobinGroupChat class by providing informative error messages for invalid inputs.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING