Group chat pattern

1 min read
On trails:AGPATstep 4/6

In a group chat, the agents talk to each other in one shared thread. It is the pattern for when the task needs a discussion, not a delegation or a fixed sequence. A manager agent mediates and produces the result. It is also called the debate pattern, a roundtable, or a council.

Three agents read from and write to one shared thread. A manager reads the thread and decides who speaks next, and stops the chat on approval or after a maximum number of rounds. Manager picks who speaks stops on approval or max rounds Shared thread every message is seen by every agent Agent 1 proposer Agent 2 critic Agent 3 specialist
Every agent sees every message. The manager picks the next speaker.

In LangGraph

The manager is a node that routes to the next speaker, or to the end. The agents all write to one shared list of messages, and a cap on rounds keeps the chat from running forever. In a real system the manager is an LLM choosing the next speaker.

Python
import operatorfrom typing import Annotated, Literal, TypedDictfrom langgraph.graph import StateGraph, START, ENDfrom langgraph.types import Command MAX_ROUNDS = 6 class Chat(TypedDict):    messages: Annotated[list[str], operator.add]   # the shared thread    rounds: int def manager(state: Chat) -> Command[Literal["proposer", "critic", "__end__"]]:    last = state["messages"][-1]    if last.startswith("APPROVE") or state["rounds"] >= MAX_ROUNDS:        return Command(goto=END)    nxt = "critic" if last.startswith("PROPOSAL") else "proposer"    return Command(goto=nxt, update={"rounds": state["rounds"] + 1}) def proposer(state: Chat): return {"messages": ["PROPOSAL: refund the order"]}def critic(state: Chat):   return {"messages": ["APPROVE: policy allows it"]} builder = StateGraph(Chat)builder.add_node("manager", manager)builder.add_node("proposer", proposer)builder.add_node("critic", critic)builder.add_edge(START, "manager")builder.add_edge("proposer", "manager")builder.add_edge("critic", "manager")graph = builder.compile()

Why use it

High quality results and flexible, adaptable behaviour. Having models propose and debate over several rounds improved factual accuracy and reasoning in the multiagent debate paper. A chat where one agent proposes and another checks is the maker and checker loop, the multi-agent form of reflectionReflectionCritique the output before finalizing it: one agent does, another reflects.Opens in a new tab.

The catch

Cost, and slowness. Every round is another model call over a growing thread. The path is non-deterministic, so two runs of the same task can differ (see agent evaluationAgent evaluationTest the flow an agent took and what it left behind, against the goal and the guardrails.Opens in a new tab). The manager also needs an objective way to know the task is done, which is why the round cap exists. Microsoft’s guide suggests keeping the group to three agents or fewer.


Sources