Consensus & Resolutions

New
Updated

After setting up a council (see Council Quick Start), you can fine-tune how decisions are made and browse the history of all past resolutions.

In this guide you'll learn how to:

  • Configure consensus algorithms
  • Browse and filter resolution history
  • Deep-dive into resolution audits
[@portabletext/react] Unknown block type "callout", specify a component for it in the `components.types` prop

Consensus Algorithms

Different algorithms aggregate votes differently. List available options and configure the one that fits your use case.

consensus-config.ts
import { Chaos } from '@chaoslabs/ai-sdk';
 
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
 
// List available algorithms
const { algorithms, default_algorithm } = await chaos.council.consensus.algorithms();
 
for (const algo of algorithms) {
  console.log(`${algo.algorithm}: ${algo.description}`);
  if (algo.parameters) {
    for (const p of algo.parameters) {
      console.log(`  param: ${p.name} (${p.type}) — ${p.description}`);
    }
  }
}
 
console.log(`\nDefault: ${default_algorithm}`);

Configure Consensus

Set the default consensus algorithm and its parameters.

set-consensus.ts
// Get current config
const current = await chaos.council.consensus.get();
console.log(`Current algorithm: ${current.algorithm}`);
 
// Update to weighted voting with minimum confidence
const updated = await chaos.council.consensus.set({
  algorithm: 'weighted_vote',
  parameters: [
    { name: 'min_confidence', value: 0.6 },
  ],
});
 
console.log(`Updated to: ${updated.algorithm}`);
[@portabletext/react] Unknown block type "callout", specify a component for it in the `components.types` prop

Browse Resolutions

View the history of all council resolutions with pagination and filtering.

browse-resolutions.ts
const { resolutions, total } = await chaos.council.resolutions.list({
  page: 1,
  pageSize: 20,
});
 
console.log(`${total} total resolutions\n`);
for (const r of resolutions) {
  console.log(`[${r.status}] ${r.query.slice(0, 60)}...`);
  console.log(`  Result: ${r.final_result ?? 'pending'}`);
  console.log(`  Council: ${r.council_name ?? 'ad-hoc'}`);
  console.log(`  Date: ${r.created_at}\n`);
}

Audit a Resolution

Dig into exactly how a decision was made — each member's vote, reasoning, confidence, and timing.

audit-resolution.ts
const sessionId = resolutions[0].session_id;
 
// Full detail
const detail = await chaos.council.resolutions.get(sessionId);
console.log(`Query: ${detail.query}`);
console.log(`Final Result: ${detail.finalResult}`);
 
// Audit trail
const audit = await chaos.council.resolutions.audit(sessionId);
 
// Summary
console.log(`\nVotes: ${audit.voteTally.completed_votes}/${audit.voteTally.total_votes}`);
for (const [choice, count] of Object.entries(audit.voteTally.choices)) {
  const pct = ((count / audit.voteTally.completed_votes) * 100).toFixed(0);
  console.log(`  ${choice}: ${count} (${pct}%)`);
}
 
// Detailed votes
for (const vote of audit.memberVotes) {
  if (vote.status !== 'completed') continue;
  console.log(`\n${vote.model_name}${vote.choice}`);
  console.log(`  Confidence: ${(vote.confidence! * 100).toFixed(0)}%`);
  console.log(`  Time: ${vote.elapsed_ms}ms`);
  console.log(`  Reasoning: ${vote.reasoning}`);
}
Was this helpful?