Skip to main content
GroupChat creates an asynchronous, self-selecting room where every agent sees every message and independently decides whether to speak. There is no fixed speaking order — agents chime in only when their self-rated desire to respond clears a threshold. This is ideal for debates, brainstorming, and complex decision-making where you want natural, emergent dialogue rather than a rigid turn order.
This page reflects the current asynchronous GroupChat. The older turn-based design — speaker_function, round-robin/random/priority speakers, @mention routing, and interactive REPL sessions — has been removed. See the GroupChat API reference for the full parameter list.

How Group Chat Works

  1. Seed — the task is broadcast to every agent’s inbox as the first message.
  2. Self-selection — for each message, every agent is asked (via a forced respond(score, message) tool call) how much it wants to speak, on a 0..1 scale.
  3. Threshold — a reply is published only when its score exceeds threshold and the message is non-empty.
  4. Concurrent broadcast — published replies wake every other agent’s inbox at once; multiple agents can react to the same message in parallel.
  5. Stop condition — the chat ends when max_loops total messages have been posted, or no new message arrives for idle_timeout seconds.

Key Characteristics

  • Asynchronous: agents listen in parallel; there is no global turn order.
  • Self-selecting: silence is the default — agents only speak when they add value.
  • Shared context: every agent sees the full transcript before deciding.
  • Bounded: max_loops caps total messages; idle_timeout ends quiet chats.
  • Auto-equipped: with auto_equip=True (default), the respond tool is injected into each agent for you.

Key Parameters

Basic Example: Tech Debate

A two-sided debate about AI’s societal impact. Each agent uses max_loops=1 and persistent_memory=False so every speaking decision is a clean single-shot call.
By default result is a formatted string (output_type="str-all-except-first"). To iterate over individual messages, set output_type="list":
Each message dict carries role (the agent name, or "User" for the seed task) and content.

Real-World Examples

Business Strategy Discussion

Executives with distinct mandates weigh in only where they have something to add.

Medical Case Conference

Tuning the Conversation

Because there is no fixed turn order, you shape the conversation with threshold, max_loops, and idle_timeout rather than a speaker function.

A livelier room

A more selective room

Bounding total length

max_loops is the primary cost control — it caps the total number of messages posted (the seed task included), not the turns per agent.

Best Practices

1. Give each agent a distinct, specific role

Distinct roles make the respond decision meaningful — agents speak inside their lane and stay quiet outside it.

2. Use max_loops=1 and persistent_memory=False per agent

Each participating agent should make a clean, single-shot decision per message. Stateful memory across decisions can distort the speaking score.

3. Tune threshold to the room size

  • Few agents (2–3): a lower threshold (~0.4–0.5) keeps the dialogue flowing.
  • Many agents (4+): raise it (~0.6–0.75) so the room doesn’t pile on every message.

4. Set idle_timeout to match thinking time

Raise it when models need longer to reason; lower it to end quiet chats faster.

5. Choose the right output_type

  • "str-all-except-first" (default) — a single readable transcript string.
  • "list" / "dict" — structured messages you can iterate (role, content).

When to Use Group Chat

Ideal for:
  • Debates and discussions — exploring opposing viewpoints.
  • Collaborative decision-making — stakeholders converging on consensus.
  • Brainstorming — emergent ideas from parallel contributions.
  • Negotiation — parties working toward agreement.
  • Peer review — evaluating work from multiple angles.

When NOT to Use Group Chat

  • Simple tasks — the coordination overhead isn’t justified (use a single Agent).
  • Independent analysis — when agents shouldn’t influence each other (use ConcurrentWorkflow).
  • Strict ordering — when a fixed sequence is required (use SequentialWorkflow).
  • Hierarchical coordination — when a director must delegate (use HierarchicalSwarm).

Comparison with Other Patterns

Learn More