OACP Docs
v2.0
Getting StartedComponentsAPI ReferenceExamplesGuides
Getting Started
Introduction
Quick Start
Installation
Basic Usage
Core Concepts
Agents
Agent Systems
Voting Strategies
Storage Backends
Adaptive Prompting
Examples
Research Team
Game AI Simulation
Content Pipeline
Code Review
Advanced Topics
Custom Voting Strategies
Custom Storage Backends
Performance Optimization
Deployment
CLI Commands
Overview
Environment Setup
Monitoring
Log Management
Web Dashboard
Advanced Commands

Voting Strategies

Explore different consensus mechanisms for multi-agent decision making and learn when to use each strategy.

Overview

Voting strategies in OACP enable multiple agents to reach consensus on decisions, solutions, or outputs. Different strategies are suitable for different scenarios and agent configurations.

Built-in Strategies

Majority Voting

The most common strategy where the option with the most votes wins.

from oacp.voting import MajorityVoting

voting_strategy = MajorityVoting()
system = AgentSystem(agents=agents, voting_strategy=voting_strategy)
Best for: Binary decisions, simple consensus scenarios

Weighted Voting

Agents have different voting weights based on their expertise or performance.

from oacp.voting import WeightedVoting

# Define weights for each agent
weights = {
    "expert_agent": 2.0,
    "junior_agent": 1.0,
    "specialist_agent": 1.5
}

voting_strategy = WeightedVoting(weights=weights)
system = AgentSystem(agents=agents, voting_strategy=voting_strategy)
Best for: When agents have different levels of expertise

Ranked Choice Voting

Agents rank options in order of preference, enabling more nuanced decision making.

from oacp.voting import RankedChoiceVoting

voting_strategy = RankedChoiceVoting()
system = AgentSystem(agents=agents, voting_strategy=voting_strategy)

# Agents provide ranked preferences
# Result is determined by instant runoff method
Best for: Multiple options, complex preference scenarios

Consensus Threshold

Requires a minimum percentage of agents to agree before a decision is made.

from oacp.voting import ConsensusThreshold

# Require 75% agreement
voting_strategy = ConsensusThreshold(threshold=0.75)
system = AgentSystem(agents=agents, voting_strategy=voting_strategy)
Best for: High-stakes decisions requiring strong agreement

Custom Voting Strategies

Create your own voting strategies by inheriting from the base VotingStrategy class.

from oacp.voting import VotingStrategy
from typing import List, Dict, Any

class PerformanceWeightedVoting(VotingStrategy):
    def __init__(self, performance_history: Dict[str, float]):
        self.performance_history = performance_history
    
    def vote(self, options: List[Any], votes: Dict[str, Any]) -> Any:
        weighted_scores = {}
        
        for agent_name, vote in votes.items():
            weight = self.performance_history.get(agent_name, 1.0)
            if vote not in weighted_scores:
                weighted_scores[vote] = 0
            weighted_scores[vote] += weight
        
        return max(weighted_scores, key=weighted_scores.get)

# Usage
performance_data = {
    "agent1": 0.95,  # High performance
    "agent2": 0.80,  # Medium performance
    "agent3": 0.70   # Lower performance
}

custom_strategy = PerformanceWeightedVoting(performance_data)
system = AgentSystem(agents=agents, voting_strategy=custom_strategy)

Choosing the Right Strategy

ScenarioRecommended StrategyReason
Equal agent expertiseMajority VotingSimple and fair when all agents are equal
Varying expertise levelsWeighted VotingGives more influence to expert agents
Multiple complex optionsRanked ChoiceCaptures nuanced preferences
Critical decisionsConsensus ThresholdEnsures strong agreement
Performance-based systemsCustom StrategyAdapts to specific requirements