Skip to main content
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:
When using @mentions:
  • Agents receive collaboration guidelines
  • Mention instructions added to system prompts
  • Context about available agents provided

Interactive Terminal Sessions

Interactive commands:
  • help or ? - Show help menu
  • exit or quit - End session
  • speaker - Change speaker selection strategy
  • @agent_name - Mention specific agents (optional)

Key Parameters

name
str
default:"GroupChat"
Name for the group chat
description
str
Description of the group chat’s purpose
agents
List[Agent]
required
List of agents participating in the chat
max_loops
int
default:"1"
Maximum number of conversation turns
speaker_function
Union[str, Callable]
Speaker selection strategy (“round-robin-speaker”, “random-speaker”, etc.)
speaker_state
dict
Configuration for speaker function (e.g., priorities, strategy)
output_type
str
default:"dict"
Output format for conversation history
interactive
bool
default:"False"
Enable interactive terminal session
rules
str
Rules to add to conversation context
time_enabled
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:
  1. ACKNOWLEDGE: Reference other agents’ contributions
  2. BUILD: Add perspective while building on insights
  3. CONTRIBUTE: Provide unique expertise
  4. COLLABORATE: Use @mentions when needed
  5. COMPLETE: Indicate task status
  6. SYNTHESIZE: Combine insights
Example Good Collaboration:

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
  1. Clear Roles: Give agents distinct perspectives/expertise
  2. Appropriate Length: 4-12 turns typically optimal
  3. Speaker Strategy: Choose based on desired interaction pattern
  4. @Mentions: Enable for targeted collaboration
  5. Max Loops: Balance thoroughness with efficiency
Conversation length grows linearly with agents and turns - monitor context window limits

Interactive Session Example

Error Handling