You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[feat][async-groupchat][rewrite groupchat as self-selecting async
chat][feat][respond-tool][export respond tool for groupchat
agents][improvement][drop-speaker-functions][remove speaker function
api from router and
exports][improvement][agent-tools-default][default
tools_list_dictionary to empty
list][improvement][groupchat-examples-refresh][update groupchat
examples to new api][feat][new-groupchat-examples][add dynamic and
router groupchat examples][feat][fable-agent-example][add fable
single agent example][docs][groupchat-docs][rewrite groupchat docs
and guides][improvement][groupchat-tests][rewrite groupchat tests for
new api]
Copy file name to clipboardExpand all lines: CLAUDE.md
+33-9Lines changed: 33 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -575,25 +575,49 @@ result = swarm.run("Produce a comprehensive competitive analysis of the AI chip
575
575
576
576
### GroupChat
577
577
578
-
Agents engage in a round-table discussion. A speaker selection function decides who speaks next. Use for brainstorming, debate, or collaborative problem-solving.
578
+
An asynchronous, self-selecting groupchat. There are no rounds or speaker-selection functions — every agent listens in parallel and decides on its own whether to chime in. A forced `respond(score, message)`function call asks each agent how much it wants to speak (0..1); replies above `threshold` are broadcast. The chat ends when `max_loops` messages have been posted or no message arrives for `idle_timeout` seconds.
579
579
580
580
```python
581
-
from swarms import Agent, GroupChat
582
-
from swarms.structs.groupchat importexpertise_based, round_robin_speaker
581
+
from swarms import Agent
582
+
from swarms.structs.groupchat importGroupChat, RESPOND_TOOL
583
583
584
-
optimist = Agent(agent_name="Optimist", system_prompt="You argue for the benefits.", model_name="gpt-4.1", max_loops=1)
585
-
pessimist = Agent(agent_name="Pessimist", system_prompt="You argue for the risks.", model_name="gpt-4.1", max_loops=1)
**Tuning:**raise `threshold` for a more selective room; lower it for livelier chats. Raise `idle_timeout` if agents need time to think before replying.
Copy file name to clipboardExpand all lines: README.md
+24-15Lines changed: 24 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -500,29 +500,38 @@ print(recommendation)
500
500
501
501
### GroupChat
502
502
503
-
`GroupChat`creates a conversational environment where multiple agents can interact, discuss, and collaboratively solve a problem. You can define the speaking order or let it be determined dynamically. This architecture is ideal for tasks that benefit from debate and multi-perspective reasoning, such as contract negotiation, brainstorming, or complex decision-making.
503
+
`GroupChat`is an asynchronous, self-selecting groupchat. All agents listen in parallel; for each broadcast message, every other agent runs a forced `respond(score, message)` function call to decide whether to chime in, and replies above `threshold` are broadcast. The chat ends when `max_loops` messages have been posted or no message arrives for `idle_timeout` seconds. There is no turn order — multiple agents can react to the same message at the same time, and silent agents stay silent.
504
504
505
505
```python
506
-
from swarms import Agent, GroupChat
506
+
from swarms import Agent, GroupChat, RESPOND_TOOL
507
507
508
-
# Define agents for a debate
509
-
tech_optimist = Agent(agent_name="TechOptimist", system_prompt="Argue for the benefits of AI in society.", model_name="gpt-5.4")
510
-
tech_critic = Agent(agent_name="TechCritic", system_prompt="Argue against the unchecked advancement of AI.", model_name="gpt-5.4")
508
+
# Every agent MUST carry RESPOND_TOOL so the chat can ask it whether to speak.
509
+
tech_optimist = Agent(
510
+
agent_name="TechOptimist",
511
+
system_prompt="Argue for the benefits of AI in society.",
512
+
model_name="gpt-4.1",
513
+
max_loops=1,
514
+
persistent_memory=False,
515
+
tools_list_dictionary=[RESPOND_TOOL],
516
+
)
517
+
tech_critic = Agent(
518
+
agent_name="TechCritic",
519
+
system_prompt="Argue against the unchecked advancement of AI.",
520
+
model_name="gpt-4.1",
521
+
max_loops=1,
522
+
persistent_memory=False,
523
+
tools_list_dictionary=[RESPOND_TOOL],
524
+
)
511
525
512
-
# Create the group chat
513
526
chat = GroupChat(
514
527
agents=[tech_optimist, tech_critic],
515
-
max_loops=4, # Limit the number of turns in the conversation
528
+
max_loops=10, # hard cap on total messages posted
529
+
threshold=0.5, # min decision score (0..1) to publish a reply
530
+
idle_timeout=8.0, # seconds of silence before stopping
516
531
)
517
532
518
-
# Run the chat with an initial topic
519
-
conversation_history = chat.run(
520
-
"Let's discuss the societal impact of artificial intelligence."
|`GroupChat`|Asynchronous self-selecting groupchat — every agent independently scores each message via a forced `respond(score, message)` tool call and broadcasts when the score clears `threshold`. |[link](swarms/structs/groupchat.py)|
51
51
|`ForestSwarm`| A forest of `Tree`s of `TreeAgent`s; routes tasks to the best matching tree leaf. |[link](swarms/structs/tree_swarm.py)|
GroupChat creates a conversational environment where multiple agents can interact, discuss, and collaboratively solve problems. Agents take turns in conversation, building on each other's ideas and reaching consensus through dialogue. This architecture is ideal for brainstorming, negotiation, and complex decision-making requiring iterative discussion.
471
+
GroupChat is an asynchronous, self-selecting room. Every agent listens to every broadcast message in parallel and independently scores how much it wants to reply via a forced `respond(score, message)` tool call. Replies whose score exceeds the configured `threshold` are broadcast back into the room. There are no rounds, no turn order, and no central speaker selector — agents decide for themselves whether each message is worth a response. The chat ends when either `max_loops` total messages have been posted or no new message arrives for `idle_timeout` seconds.
472
472
473
473
Best For: GroupChat is ideal for brainstorming sessions, negotiation and debate, collaborative problem-solving, real-time decision-making, creative ideation, and contract or agreement drafting.
474
474
475
-
Advantages: This architecture enables natural conversational interaction, builds on collective intelligence, allows for clarification and follow-up, and mimics human collaborative processes.
475
+
Advantages: This architecture lets specialised agents stay silent on messages outside their expertise, mixes model providers transparently, and scales to many participants without a coordinator bottleneck.
476
476
477
-
Trade-offs: GroupChat can be unpredictable in direction, may require careful moderation, has conversation length that can be variable, and is not suitable for time-critical tasks.
477
+
Trade-offs: GroupChat can be unpredictable in direction, requires `threshold` tuning to avoid either silent rooms or runaway chatter, has variable conversation length, and is not suitable for time-critical tasks.
478
478
479
479
### Architecture Diagram
480
480
@@ -499,50 +499,54 @@ graph TD
499
499
### Code Example
500
500
501
501
```python
502
-
from swarms import Agent, GroupChat
502
+
from swarms import Agent, GroupChat, RESPOND_TOOL
503
+
504
+
# Define agents with different perspectives for an asynchronous discussion.
505
+
# Every participant must include tools_list_dictionary=[RESPOND_TOOL] so the
506
+
# chat can read each agent's structured (score, message) decision.
503
507
504
-
# Define agents with different perspectives for a debate
505
508
optimist = Agent(
506
509
agent_name="TechnologyOptimist",
507
510
system_prompt="Argue for the benefits and opportunities of AI advancement. Focus on positive impacts.",
508
511
model_name="anthropic/claude-sonnet-4-5",
509
-
top_p=None,
510
512
max_loops=1,
511
-
dynamic_temperature_enabled=True,
513
+
persistent_memory=False,
514
+
tools_list_dictionary=[RESPOND_TOOL],
512
515
)
513
516
514
517
critic = Agent(
515
518
agent_name="TechnologyCritic",
516
519
system_prompt="Critically examine AI development challenges, risks, and potential negative consequences.",
517
520
model_name="anthropic/claude-sonnet-4-5",
518
-
top_p=None,
519
521
max_loops=1,
520
-
dynamic_temperature_enabled=True,
522
+
persistent_memory=False,
523
+
tools_list_dictionary=[RESPOND_TOOL],
521
524
)
522
525
523
526
ethicist = Agent(
524
527
agent_name="EthicsSpecialist",
525
528
system_prompt="Focus on ethical implications, responsible AI development, and societal considerations.",
526
529
model_name="anthropic/claude-sonnet-4-5",
527
-
top_p=None,
528
530
max_loops=1,
529
-
dynamic_temperature_enabled=True,
531
+
persistent_memory=False,
532
+
tools_list_dictionary=[RESPOND_TOOL],
530
533
)
531
534
532
535
moderator = Agent(
533
536
agent_name="Moderator",
534
537
system_prompt="Facilitate constructive dialogue, ensure all voices are heard, and help reach balanced conclusions.",
535
538
model_name="anthropic/claude-sonnet-4-5",
536
-
top_p=None,
537
539
max_loops=1,
538
-
dynamic_temperature_enabled=True,
540
+
persistent_memory=False,
541
+
tools_list_dictionary=[RESPOND_TOOL],
539
542
)
540
543
541
-
# Create the group chat with controlled conversation length
544
+
# Create the group chat. Replies are broadcast only when score > threshold.
542
545
chat = GroupChat(
543
546
agents=[optimist, critic, ethicist, moderator],
544
-
max_loops=6, # Limit conversation turns for focused discussion
Copy file name to clipboardExpand all lines: docs/swarms/concept/swarm_architectures.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ Multi-agent architectures leverage these communication patterns to ensure that a
26
26
| Sequential Coordination | Agents perform tasks in a specific sequence, where the completion of one task triggers the start of the next. |[Learn More](https://docs.swarms.world/swarms/structs/sequential_workflow/)| Step-by-step assembly lines, sequential sales processes, stepwise patient treatment workflows |
27
27
| Mixture of Agents | A heterogeneous architecture where agents with different capabilities are combined to solve complex problems. |[Learn More](https://docs.swarms.world/swarms/structs/moa/)| Financial forecasting, complex problem-solving requiring diverse skills |
28
28
| Graph Workflow | Agents collaborate in a directed acyclic graph (DAG) format to manage dependencies and parallel tasks. |[Learn More](https://docs.swarms.world/swarms/structs/graph_workflow/)| AI-driven software development pipelines, complex project management |
29
-
| Group Chat |Agents engage in a chat-like interaction to reach decisions collaboratively. |[Learn More](https://docs.swarms.world/swarms/structs/group_chat/)| Real-time collaborative decision-making, contract negotiations |
29
+
| Group Chat |Asynchronous self-selecting chat — each agent independently scores whether each message warrants a reply.|[Learn More](https://docs.swarms.world/swarms/structs/group_chat/)| Real-time collaborative decision-making, contract negotiations |
30
30
| Interactive Group Chat | Enhanced group chat with dynamic speaker selection and interaction patterns. |[Learn More](https://docs.swarms.world/swarms/structs/interactive_groupchat/)| Advanced collaborative decision-making, dynamic team coordination |
31
31
| SpreadSheet | Manages tasks at scale, tracking agent outputs in a structured format like CSV files. |[Learn More](https://docs.swarms.world/swarms/structs/spreadsheet_swarm/)| Large-scale marketing analytics, financial audits |
32
32
| Router | Routes and chooses the architecture based on the task requirements and available agents. |[Learn More](https://docs.swarms.world/swarms/structs/swarm_router/)| Dynamic task routing, adaptive architecture selection, optimized agent allocation |
@@ -347,7 +347,7 @@ graph TD
347
347
### Group Chat
348
348
349
349
**Overview:**
350
-
Enables agents to engage in chat-like interactions to reach decisions collaboratively through discussion and consensus building.
350
+
An asynchronous, self-selecting room where every agent listens to every broadcast message in parallel and independently scores whether to reply via a forced `respond(score, message)` tool call. Replies above the configured `threshold` are broadcast back into the room; the chat ends when `max_loops` messages have been posted or no new message arrives for `idle_timeout` seconds.
0 commit comments