Skip to content

Social Choice & Voting

Some decisions should not be made by a single agent. Which agent should take this task? Which of several candidate answers is correct? Which plan should the group follow? Social choice is the branch of decision theory that studies how to combine individual preferences into a collective decision, and this sub-system brings it to agents: a group of agents each cast a vote, and a voting strategy turns those votes into one outcome.

Why it matters

  • Robustness — aggregating several independent opinions reduces the impact of one agent's mistake or hallucination.
  • Fairness and transparency — the decision rule (majority, weighted, and so on) is explicit rather than hidden inside one agent's prompt.
  • Building block for other systems — voting is used by Task Delegation to pick a delegate and by the Verification System for multi-agent verification.

How it works

  1. An agent creates a social task through the REST API, describing the goal data, the participating agents, and the voting strategy.
  2. Participants are invited and submit their votes.
  3. When voting completes, the final result is published on NATS, where the initiating agent receives it.

At a Glance

The Social Choice & Voting System coordinates collaborative decision-making among multiple agents. It provides:

  • REST APIs to create and manage social tasks (voting workflows).
  • NATS integration for receiving final voting results in real time.
  • Support for multiple voting strategies (e.g., majority, weighted).

A typical client workflow is:

  1. Create a social voting task via REST.
  2. Invite participants and define the goal data.
  3. Wait for voting completion via NATS.
  4. Retrieve and process the voting result.

Registering Social Choice & Voting System in Subject Specification

Add a SubSystemItem entry so the agent can connect to the social voting APIs and NATS result stream.

Data Class Reference

@dataclass
class SubSystemItem:
    sub_system_id: str
    sub_system_type: str = ""
    sub_system_config: Dict[str, Any] = field(default_factory=dict)

Minimal Required Configuration

{
  "sub_system_id": "social-choice-voting-01",
  "sub_system_type": "social-choice-voting",
  "sub_system_config": {
    "api_base_url": "http://social-voting-api.default.svc.cluster.local:5001",
    "nats_url": "nats://nats.default.svc.cluster.local:4222"
  }
}

Fields

  • api_base_url – REST API base path for social task operations.
  • nats_url – NATS connection for streaming voting results.

Import and Setup

from agent_sdk.verification import SocialTaskService

service = SocialTaskService("http://localhost:5001")

Usage Guide

Creating a Social Task

task = service.create_social_task(
    created_by_subject_id="agent_a",
    voting_type="majority",
    invited_subject_ids=["agent_b", "agent_c"],
    goal_data={"decision": "select_strategy"},
    status="pending",
    report={},
    voting_pqt_dsl_id="dsl_123",
    choice_evaluation_dsl="eval_dsl",
    deadline_time=1688888888
)

print("Created Social Task:", task.social_task_id)

Waiting for Voting Result via NATS

waiter = service.create_waiter_for_task(task_id=task.social_task_id)
result = waiter.get()
print("Voting Result:", result.voting_result)