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
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.mjsRead the full example: examples/19_discussion.mjs →