All agents in an AG2 GroupChat must have unique names. If you attempt to create a GroupChat with duplicate agent names, a ValueError is raised. The fix is a one-minute name check before you start the chat.
Before you start
You need an AG2 group chat that fails to start, or a new one you are about to create. List the agent names on paper first: duplicates are easy to create when two agents share a role, for example two researchers.
List the names and find the duplicate
Print the name of every agent in the group chat list. Look for exact duplicates, including two agents created from the same helper function with the same default name. Rename the duplicate with a role suffix, for example researcher_web and researcher_docs, instead of researcher twice.
Recreate the GroupChat and confirm it starts
Create the GroupChat again with the renamed agents and start the chat with a short request. If it starts, the duplicate was the cause. Keep a naming rule for the project: one name per agent, written down in the crew file, so the next agent added does not repeat one.
Worked example: Duplicate names in a fictional research group
Maple Research is a fictional research desk. Its group chat failed to start. The table shows the name check.
| Agent | Name before | Name after |
|---|---|---|
| Researcher 1 | researcher | researcher_web |
| Researcher 2 | researcher | researcher_docs |
| Writer | writer | writer |
| Critic | critic | critic |
Expected result (UNTESTED): the chat starts after the rename, with four agents named researcher_web, researcher_docs, writer and critic. We checked the AG2 GroupChat documentation, which states the unique-name rule and the ValueError, but we did not run the chat on this machine.
Limits
Unique names fix the start error, not routing errors: two agents with different names but identical descriptions still confuse the manager. Write a distinct description for each agent as well as a distinct name.
