GroupChat creates a conversational environment where multiple agents can interact, discuss, and collaboratively solve problems. Support for various speaker selection strategies and interactive terminal sessions makes it ideal for debate, brainstorming, and complex decision-making.
When to Use
- Debate and discussion: Multiple perspectives on complex topics
- Collaborative problem-solving: Agents work together through conversation
- Brainstorming: Generate ideas through multi-agent interaction
- Contract negotiation: Back-and-forth discussion with stakeholders
- Interactive sessions: Human-in-the-loop group conversations
Key Features
- Multiple speaker selection strategies
- @mention support for agent targeting
- Interactive REPL terminal sessions
- Conversation history tracking
- Collaborative response protocols
- Dynamic speaker function switching
- Time-stamped messages
Basic Example
Speaker Selection Strategies
Round Robin
Agents speak in order, cycling through the list:Random Speaker
Randomly select one agent per turn:Priority-Based
Select agents based on priority weights:Random Dynamic
First speaker random, then follows @mentions:@Mention Support
Agents can reference each other using @mentions:- Agents receive collaboration guidelines
- Mention instructions added to system prompts
- Context about available agents provided
Interactive Terminal Sessions
helpor?- Show help menuexitorquit- End sessionspeaker- Change speaker selection strategy@agent_name- Mention specific agents (optional)
Key Parameters
str
default:"GroupChat"
Name for the group chat
str
Description of the group chat’s purpose
List[Agent]
required
List of agents participating in the chat
int
default:"1"
Maximum number of conversation turns
Union[str, Callable]
Speaker selection strategy (“round-robin-speaker”, “random-speaker”, etc.)
dict
Configuration for speaker function (e.g., priorities, strategy)
str
default:"dict"
Output format for conversation history
bool
default:"False"
Enable interactive terminal session
str
Rules to add to conversation context
bool
default:"True"
Include timestamps in messages
Methods
run()
Execute the group chat with a task.start_interactive_session()
Start an interactive REPL session.set_speaker_function()
Dynamically change speaker selection:get_available_speaker_functions()
List all available speaker strategies:Collaborative Response Protocol
Agents automatically receive collaboration guidelines: Response Structure:- ACKNOWLEDGE: Reference other agents’ contributions
- BUILD: Add perspective while building on insights
- CONTRIBUTE: Provide unique expertise
- COLLABORATE: Use @mentions when needed
- COMPLETE: Indicate task status
- SYNTHESIZE: Combine insights
Use Cases
Debate System
Research Collaboration
Customer Service Team
Custom Speaker Functions
Conversation Context
Agents receive complete context:Agent Context Prompt
Automatic prompt augmentation:Sequential vs Parallel Strategies
Sequential Strategy
One mentioned agent responds at a time:Parallel Strategy
All mentioned agents respond simultaneously:Output Formats
Best Practices
Speaker Selection: Match strategy to task - round robin for equal participation, priority for expert weighting
- Clear Roles: Give agents distinct perspectives/expertise
- Appropriate Length: 4-12 turns typically optimal
- Speaker Strategy: Choose based on desired interaction pattern
- @Mentions: Enable for targeted collaboration
- Max Loops: Balance thoroughness with efficiency
Interactive Session Example
Error Handling
Related Architectures
- Hierarchical Swarm - Structured coordination
- Mixture of Agents - Parallel with synthesis
- Social Algorithms - Custom communication patterns
- Agent Rearrange - Custom flows