Skip to content

Orchestration: Group Chat

Key Points

  • Multiple agents converse like humans in a meeting. Manager / chair decides who speaks next.
  • Use for brainstorming, debate, consensus-seeking, role-playing scenarios.
  • More expensive than sequential/concurrent (more rounds).
  • Termination condition critical — without it, infinite chat.

Concept

[User] → [Group Chat]
            ├── Speaker selection (manager) → [Agent A speaks]
            │                              ↓
            ├── Speaker selection         → [Agent B speaks]
            │                              ↓
            ├── Speaker selection         → [Agent C speaks]
            └── Termination check         → done?

Code

var pm = new ChatClientAgent(chat) { Name = "PM", Instructions = "Drive the discussion toward a decision." };
var dev = new ChatClientAgent(chat) { Name = "Dev", Instructions = "Provide technical perspective." };
var qa = new ChatClientAgent(chat) { Name = "QA", Instructions = "Provide quality / testing perspective." };

var orchestration = new GroupChatOrchestration(
    members: [pm, dev, qa],
    selectionStrategy: new RoundRobinSelectionStrategy(),
    terminationStrategy: new MaxTurnsTerminationStrategy(maxTurns: 6));

var response = await orchestration.InvokeAsync("Should we ship this feature next sprint?");

Selection strategies

Round-robin

Each agent speaks once per round. Simple; predictable.

Manager-driven

A "manager" LLM picks who should speak next:

public class ManagerSelectionStrategy(IChatClient chat) : ISpeakerSelectionStrategy
{
    public async Task<Agent> SelectNextAsync(IList<ChatMessage> history, IList<Agent> candidates, CancellationToken ct)
    {
        var prompt = $"Given the conversation, who should speak next? Choose from: {string.Join(", ", candidates.Select(a => a.Name))}";
        var resp = await chat.GetResponseAsync(prompt + "\n\n" + Serialize(history), cancellationToken: ct);
        return candidates.First(a => resp.Text.Contains(a.Name));
    }
}

More natural; costs an extra LLM call per turn.

Custom

Domain-specific (e.g., "QA always responds when 'bug' mentioned").

Termination strategies

Max turns

Hard limit; e.g., 10 turns.

Manager decides

Manager LLM checks each turn: "Is the discussion concluded? Yes/No".

Convergence

Stop when last 2 turns agree.

Combined

Multiple criteria (max turns AND manager-decided).

Use cases

  • Decision-making: PM/Dev/QA debate a feature.
  • Brainstorming: marketing/design/eng generate ideas.
  • Role-play: training simulators.
  • Multi-perspective writing: critique among personas.

Cost

Highest of the orchestration patterns. N agents × M turns × ~few K tokens each. Easy to hit $1+/run with frontier models.

6 turns * 3 agents * 5K tokens * (gpt-4o input $2.50/M + output $10/M) = ~$0.50

Watch the budget.

Streaming

await foreach (var update in orchestration.InvokeStreamingAsync(prompt))
{
    Console.WriteLine($"[{update.AgentName}] {update.Text}");
}

UI shows turn-by-turn.

When NOT group chat

  • Linear pipeline → sequential.
  • Independent reviews → concurrent.
  • Routing decisions → handoff.

Senior considerations

  • Termination is essential — infinite chat otherwise.
  • Cost monitoring — high; cap per request.
  • Persona discipline — agents drift; reinforce instructions.
  • Logging every turn for debug.
  • Eval: hard. LLM-as-judge or human review.

Anti-patterns

  • ❌ No termination condition.
  • ❌ All agents have similar instructions (no real conversation).
  • ❌ Group chat for tasks that don't need it.

Cross-references