Swarm Type: MajorityVoting

Overview

The MajorityVoting swarm type implements a democratic decision-making process where multiple agents independently analyze a problem and propose solutions. The final outcome is determined by majority consensus, making this architecture ideal for scenarios where you want to leverage collective intelligence while maintaining a clear decision-making process. Key features:
  • Democratic Decision Making: Multiple agents vote on solutions
  • Consensus Building: Majority rule determines final outcome
  • Independent Analysis: Each agent works independently before voting
  • Transparent Process: Clear voting mechanism and results

Use Cases

  • Content quality assessment and approval
  • Problem diagnosis with multiple expert opinions
  • Decision-making in uncertain scenarios
  • Quality control and validation processes

API Usage

Basic MajorityVoting Example

curl -X POST "https://api.swarms.world/v1/swarm/completions" \
  -H "x-api-key: $SWARMS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Content Quality Assessment",
    "description": "Multi-agent content review with majority voting for approval",
    "swarm_type": "MajorityVoting",
    "task": "Review and vote on whether to approve this marketing content for publication: [Content: Our revolutionary AI solution transforms business operations by leveraging cutting-edge machine learning algorithms to optimize workflows and increase productivity by up to 300%]",
    "agents": [
      {
        "agent_name": "Marketing Expert",
        "description": "Evaluates marketing effectiveness and messaging",
        "system_prompt": "You are a marketing expert. Assess marketing content for effectiveness, clarity, and appeal to target audiences. Vote YES if the content is ready for publication, NO if it needs revision.",
        "model_name": "gpt-4o",
        "max_loops": 1,
        "temperature": 0.3
      },
      {
        "agent_name": "Technical Reviewer",
        "description": "Reviews technical accuracy and claims",
        "system_prompt": "You are a technical reviewer. Assess the technical accuracy of claims and ensure they are substantiated. Vote YES if claims are accurate, NO if they are exaggerated or unsubstantiated.",
        "model_name": "gpt-4o",
        "max_loops": 1,
        "temperature": 0.2
      },
      {
        "agent_name": "Legal Compliance",
        "description": "Checks for legal and compliance issues",
        "system_prompt": "You are a legal compliance expert. Review content for potential legal issues, compliance concerns, and regulatory requirements. Vote YES if content is compliant, NO if there are legal concerns.",
        "model_name": "gpt-4o",
        "max_loops": 1,
        "temperature": 0.1
      },
      {
        "agent_name": "Brand Guardian",
        "description": "Ensures brand consistency and voice",
        "system_prompt": "You are a brand guardian. Ensure content aligns with brand voice, values, and positioning. Vote YES if content fits the brand, NO if it needs brand alignment adjustments.",
        "model_name": "gpt-4o",
        "max_loops": 1,
        "temperature": 0.4
      }
    ],
    "max_loops": 1
  }'
Example Response:
{
    "job_id": "swarms-V17nZFDesmLHxCRoeyF3NVYvPaXk",
    "status": "success",
    "swarm_name": "Content Quality Assessment",
    "description": "Multi-agent content review with majority voting for approval",
    "swarm_type": "MajorityVoting",
    "output": [
        {
            "role": "Marketing Expert",
            "content": "VOTE: YES. The content effectively communicates the value proposition and uses compelling language that would resonate with business audiences.",
            "vote": "YES"
        },
        {
            "role": "Technical Reviewer",
            "content": "VOTE: NO. The claim of '300% productivity increase' is not substantiated and could be considered misleading without specific data.",
            "vote": "NO"
        },
        {
            "role": "Legal Compliance",
            "content": "VOTE: NO. The unsubstantiated productivity claim could potentially violate advertising standards and truth-in-advertising regulations.",
            "vote": "NO"
        },
        {
            "role": "Brand Guardian",
            "content": "VOTE: YES. The content aligns well with our brand voice of innovation and transformation.",
            "vote": "YES"
        }
    ],
    "voting_result": "REJECTED (2 NO votes, 2 YES votes - requires majority)",
    "number_of_agents": 4,
    "service_tier": "standard",
    "execution_time": 28.7,
    "usage": {
        "input_tokens": 50,
        "output_tokens": 1800,
        "total_tokens": 1850,
        "billing_info": {
            "cost_breakdown": {
                "agent_cost": 0.04,
                "input_token_cost": 0.00015,
                "output_token_cost": 0.027,
                "token_counts": {
                    "total_input_tokens": 50,
                    "total_output_tokens": 1800,
                    "total_tokens": 1850
                },
                "num_agents": 4,
                "service_tier": "standard",
                "night_time_discount_applied": true
            },
            "total_cost": 0.06715,
            "discount_active": true,
            "discount_type": "night_time",
            "discount_percentage": 75
        }
    }
}

Best Practices

  • Use an odd number of agents to avoid tie votes
  • Design agents with distinct evaluation criteria
  • Ensure clear voting instructions in system prompts
  • Ideal for quality control and approval workflows