Skip to content

< CollectionsA multi-agent research system · 8 of 9 ·91 · Level 05, Agents

Pick the Answer When One Subagent Is Wrong

medium · implement · Agents

Five subagents answer the same question. One of them is confidently wrong, and you do not know which. Implement aggregate(votes), which picks the answer the swarm stands behind.

Each vote is {"agent": name, "answer": text or None, "confidence": 0 to 1}. Return {"answer": ..., "support": ..., "dissent": [...]}.

  1. Compare answers in a normalised form: strip(), casefold(), inner whitespace collapsed to one space, trailing ., ! and ? removed. "Paris." and " paris" are the same vote.
  2. An agent whose answer is None or blank abstains. It is not a voter, and it is not in dissent.
  3. The winner is the normalised answer with the most votes. On a tie, the one with the higher total confidence. Still tied, the one that appeared first.
  4. answer is the earliest winning voter's original text, stripped. support is winning votes over all voters, rounded to two places. dissent lists the agents, in order, whose answer was not the winner.
  5. With no voters at all, return {"answer": None, "support": 0.0, "dissent": []}.

Majority voting is the cheapest defence against a single wrong subagent, and it is only as good as the comparison: two agents that agree in different words must count as agreeing.