Advanced Orchestration Engines ⏱ 11 min read 📁 examples/19_discussion.mjs

Lesson 15: Multi-Agent Discussion and Consensus

Orchestrate multi-agent deliberation: structured debate rounds, passing criteria, LLM-as-a-judge evaluation, and synthesis aggregation.

1. Why This Feature Exists

Single agents suffer from cognitive blind spots. A multi-agent discussion swarm combines opposing viewpoints (e.g. Architect, Security Engineer, Performance Specialist) to stress-test designs and arrive at robust consensus.

2. Key Symbols and Exports

DiscussionSession
Manages a swarm of distinct persona agents focused on a shared objective.
Debate Rounds & allowPass
Agents debate sequentially; can pass when consensus is reached or their perspective is satisfied.
group.judge()
Impartial judge evaluates whether arguments meet acceptance criteria.
group.aggregate()
Synthesizes all perspectives and findings into a final authoritative consensus document.

3. Implementation Walkthrough

import {
    ProviderType,
    resolveProvider,
    initializeClient,
    loadCredentials,
    getDefaultModel,
    DiscussionSession
} from 'merci-sdk';

const PROVIDER = resolveProvider();
const { client } = await initializeClient({ provider: PROVIDER, options: loadCredentials({ provider: PROVIDER }) });

const discussion = new DiscussionSession(client, {
    model: getDefaultModel({ provider: PROVIDER }),
    objective: 'Select the optimal database architecture for high-throughput real-time analytics.',
    agents: [
        { name: 'DataArchitect', perspective: 'Data modeling, columnar storage, ClickHouse vs PostgreSQL.' },
        { name: 'SRE_Lead', perspective: 'Operational complexity, replication, backup strategies, and cost.' },
        { name: 'SecurityAuditor', perspective: 'Encryption at rest/in transit, RBAC, and audit logging.' }
    ],
    maxRounds: 2
});

// 1. Run structured debate
await discussion.runDebate();

// 2. Render consensus verdict
const verdict = await discussion.judge();

// 3. Aggregate final deliverable
const finalReport = await discussion.aggregate('Generate comprehensive decision document.');
console.log('Final Consensus:', finalReport);

4. Wire and Telemetry Mechanics

The discussion ledger maintains turns with author tags. Each turn feeds preceding arguments to the active agent, followed by an impartial judge prompt.

5. Run the Example

Execute the runnable example directly from the repository root:

node examples/19_discussion.mjs

Read the full example: examples/19_discussion.mjs →

Expected Output: Runs debate between 3 personas across 2 rounds, displays real-time agent arguments, and outputs judge verdict and final consensus report.